Skip to content

Instantly share code, notes, and snippets.

@capaj
Last active August 29, 2021 14:14
Show Gist options
  • Save capaj/d9fb9660f49d15fc8319d3f310e77c0a to your computer and use it in GitHub Desktop.
Save capaj/d9fb9660f49d15fc8319d3f310e77c0a to your computer and use it in GitHub Desktop.
socket.io acknowledge node.js sample
var io = require('socket.io')(8090);
io.on('connection', function (socket) {
console.log('connected')
socket.on('ferret', function (name, fn) {
console.log('ferret')
fn('woot');
});
});
const ioClient = require('socket.io-client');
var client = ioClient.connect('http://localhost:8090');
client.emit('ferret', 'tobu', () => {
console.log('ack')
});
@adrianjmejias
Copy link

Really useful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment