I'm trying to create a game where the browser in the desktop is one view and a mobile device is another view. You use the mobile device as the game controller to make characters in the desktop move. It is similar to chrome.com/supersyncsports.
Using socket.io, what is the best way to sync a mobile device to a desktop client? chrome.com/supersyncsports uses a code to sync the two clients. Are they using something similar to socket.io's namespacing or rooms, where the code is the name of room?
I'm looking for a way to sync the two clients and make sure data is only emitted to the correct device and connection and not all connections. What is the best of achieving this using socket.io?
As film42 said, the code entry is probably the best way to do it, using something like this server side:
socket.on('room', function(room) {
if(io.sockets.clients(room)>=2){
socket.emit('error':"too Many connections")
}
else{
socket.join(room);
}
});
allows you to limit each room to two clients
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With