-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 795 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const express = require('express')
const socket = require('socket.io')
const app = express()
app.use(express.static("public"))
let port = 5000
let server = app.listen(port, ()=>{
console.log("Listening to ", port)
})
let io = socket(server)
io.on("connection", (socket) => {
console.log("Made socket connection")
// Recieved Data
socket.on("beginPathToServer", (data) => {
// Transfer to all connected devices
io.sockets.emit("beginPathToServer", data)
})
socket.on("drawStrokeServer", (data) => {
io.sockets.emit("drawStrokeServer", data)
})
socket.on("undoRedoListDraw", (data) => {
io.sockets.emit("undoRedoListDraw", data)
})
socket.on("redoUndo", (data) => {
io.sockets.emit("redoUndo", data);
})
})