fix different whiteboard interference
This commit is contained in:
parent
88a2fe0dda
commit
f5311bcc97
@ -26,6 +26,8 @@ signaling_socket.on('connect', function () {
|
|||||||
signaling_socket.on('refreshUserBadges', function () {
|
signaling_socket.on('refreshUserBadges', function () {
|
||||||
whiteboard.refreshUserBadges();
|
whiteboard.refreshUserBadges();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
signaling_socket.emit('joinWhiteboard', whiteboardId);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
20
server.js
20
server.js
@ -70,18 +70,36 @@ function progressUploadFormData(formData) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allUsers = {};
|
||||||
io.on('connection', function(socket){
|
io.on('connection', function(socket){
|
||||||
|
|
||||||
socket.on('disconnect', function () {
|
socket.on('disconnect', function () {
|
||||||
|
delete allUsers[socket.id];
|
||||||
socket.broadcast.emit('refreshUserBadges', null);
|
socket.broadcast.emit('refreshUserBadges', null);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('drawToWhiteboard', function(content) {
|
socket.on('drawToWhiteboard', function(content) {
|
||||||
content = escapeAllContentStrings(content);
|
content = escapeAllContentStrings(content);
|
||||||
socket.broadcast.emit('drawToWhiteboard', content);
|
sendToAllUsersOfWhiteboard(content["wid"], content)
|
||||||
s_whiteboard.handleEventsAndData(content); //save whiteboardchanges on the server
|
s_whiteboard.handleEventsAndData(content); //save whiteboardchanges on the server
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('joinWhiteboard', function(wid) {
|
||||||
|
allUsers[socket.id] = {
|
||||||
|
"socket" : socket,
|
||||||
|
"wid" : wid
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function sendToAllUsersOfWhiteboard(wid, content) {
|
||||||
|
for(var i in allUsers) {
|
||||||
|
if(allUsers[i]["wid"]==wid) {
|
||||||
|
allUsers[i]["socket"].emit('drawToWhiteboard', content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Prevent cross site scripting
|
//Prevent cross site scripting
|
||||||
function escapeAllContentStrings(content, cnt) {
|
function escapeAllContentStrings(content, cnt) {
|
||||||
if(!cnt)
|
if(!cnt)
|
||||||
|
Loading…
Reference in New Issue
Block a user