commit 93d03e04414881dbbcd9c296aea236827a5ae636 Author: joak Date: Tue Feb 6 09:37:15 2024 +0100 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fb3f7e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules/* +package-lock.json diff --git a/index.js b/index.js new file mode 100644 index 0000000..7547ad4 --- /dev/null +++ b/index.js @@ -0,0 +1,25 @@ +const express = require('express'); +const app = express(); +const http = require('http'); +const server = http.createServer(app); +const { Server } = require("socket.io"); +const io = new Server(server); + +app.use(express.static('public')); + +io.on('connection', (socket) => { + console.log('a user connected'); + + socket.on('draw', (line) => { + console.log(line); + socket.broadcast.emit("draw",line); + }); + + socket.on('disconnect', () => { + console.log('user disconnected'); + }); +}); + +server.listen(3000, () => { + console.log('listening on *:3000'); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..058184c --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "name": "collective drawing on canvas", + "version": "0.0.1", + "description": "lets draw together", + "dependencies": { + "express": "^4.18.2", + "socket.io": "^4.7.4" + } +} diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..5c48a31 --- /dev/null +++ b/public/index.html @@ -0,0 +1,81 @@ + + + + untitled + + + + + + + Width: + Color: + + + +