Last active
August 29, 2021 14:14
-
-
Save capaj/d9fb9660f49d15fc8319d3f310e77c0a to your computer and use it in GitHub Desktop.
socket.io acknowledge node.js sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really useful, thanks!