diff --git a/common/types/global.d.ts b/common/types/global.d.ts index 55e047c..9ea07bf 100644 --- a/common/types/global.d.ts +++ b/common/types/global.d.ts @@ -9,6 +9,7 @@ export declare global { options: CtxOptions, userId: string ) => void; + user_undo(userId: string): void; mouse_moved: (x:number, y:number, socketId: string) => void; users_in_room: (socketIds: string[]) => void; user_disconnected: (socketId: string) => void; diff --git a/server/index.ts b/server/index.ts index 288ebf6..b7c2e2c 100644 --- a/server/index.ts +++ b/server/index.ts @@ -27,7 +27,7 @@ io.on("connection", (socket)=>{ socket.on("draw", (moves, options)=>{ console.log("drawing"); - socket.broadcast.emit("socket_draw", moves, options); + socket.broadcast.emit("user_draw", moves, options, socket.id); }); socket.on("mouse_move", (x,y) => { @@ -36,6 +36,11 @@ io.on("connection", (socket)=>{ }); + socket.on("undo", ()=>{ + console.log("undo"); + socket.broadcast.emit("user_undo", socket.id); + }); + socket.on("disconnect", ()=>{ console.log("disconnected"); });