Publication on the server emits an emit to inform the client the publication has been handled. This can be replaced with the ack option.
socket.send([...args][, ack])
args
ack (Function)
Returns Socket
Sends a message event. See socket.emit(eventName[, ...args][, ack]).
socket.emit(eventName[, ...args][, ack])
eventName (String)
args
ack (Function)
Returns Socket
Emits an event to the socket identified by the string name. Any other parameters can be included. All serializable datastructures are supported, including Buffer.
socket.emit('hello', 'world');
socket.emit('with-binary', 1, '2', { 3: '4', 5: new Buffer(6) });
The ack argument is optional and will be called with the server answer.
socket.emit('ferret', 'tobi', (data) => {
console.log(data); // data will be 'woot'
});
Publication on the server emits an emit to inform the client the publication has been handled. This can be replaced with the ack option.
socket.send([...args][, ack]) args ack (Function) Returns Socket Sends a message event. See socket.emit(eventName[, ...args][, ack]).
socket.emit(eventName[, ...args][, ack])
eventName (String) args ack (Function) Returns Socket Emits an event to the socket identified by the string name. Any other parameters can be included. All serializable datastructures are supported, including Buffer.
socket.emit('hello', 'world'); socket.emit('with-binary', 1, '2', { 3: '4', 5: new Buffer(6) }); The ack argument is optional and will be called with the server answer.
socket.emit('ferret', 'tobi', (data) => { console.log(data); // data will be 'woot' });
// server: // io.on('connection', (socket) => { // socket.on('ferret', (name, fn) => { // fn('woot'); // }); // });
socket.on(