Using socketio on the client side and nodejs with socketio on the server side, how would I go about passing data from the client side to the server? Would I use an emit function with socketio on the client side?
Yes. Client side or server side you simply emit events and handle events.
client side:
var socket = io.connect('http://localhost');
socket.emit('my other event', { my: 'data' });
server side:
io.sockets.on('connection', function (socket) {
socket.on('my other event', function (data) {
console.log(data);
});
});
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