In my case I have to sync repositories via socket using socket.io. On my local machine it's working well (high bandwith no latency...). But I tought about emiting bigger objects to server and then some locking is required on client during sending these objects.
So the first known possible way is to emmit a "gotData and" listen on client. But is there an way to detect completion only from client side?
e.g. Like the DUMMY example:
//Some dummy code
socket.emit('syncObject', oObj).complete(function(evt){
console.log('finished emit');
});
This is a little bit of a hack but you can include a callback with your emit and immediately call it on the server side when it receives the message.
client
socket.emit('syncObject', oObj, function() {
console.log('got message');
});
server
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
socket.on('syncObject', function (obj, cb) {
cb();
// handle obj data
});
});