Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions public/javascripts/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ socket.emit('sync', { path: pathname })

// Set TextArea as server response
socket.on('notify', function (data) {
if (data.path == pathname) {
document.getElementById('text').value = data.content
} else {
console.log('Recieved: ' + data.path + ' Have: ' + pathname)
}
document.getElementById('text').value = data.content
})

// Send latest data to server
Expand Down
5 changes: 4 additions & 1 deletion routes/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = function (io) {

// Handle sync request
socket.on('sync', function (data) {
// Join room with all users for this pad
socket.join(data.path)

if (pages.has(data.path)) {
// Page exists, notify with pad data
notify(socket, pages.get(data.path), data.path)
Expand Down Expand Up @@ -44,7 +47,7 @@ module.exports = function (io) {

// Send update to all clients
function notifyAll (socket, c, p) {
socket.broadcast.emit('notify', { content: c, path: p })
socket.to(p).emit('notify', { content: c, path: p })
}

// Clean up memory if Map gets too full
Expand Down