Skip to content

Instantly share code, notes, and snippets.

@xcoderzach
Created March 17, 2011 19:00
Show Gist options
  • Save xcoderzach/874911 to your computer and use it in GitHub Desktop.
Save xcoderzach/874911 to your computer and use it in GitHub Desktop.
var http = require('http')
, io = require('socket.io') // for npm, otherwise use require('./path/to/socket.io')
, clients = {}
, server = http.createServer(function(req, res){
// your normal server code
})
server.listen(80)
function sendToClient(id, message) {
clients[id].send(message)
}
var socket = io.listen(server)
socket.on('connection', function(client){
clients[client.sessionId] = client
client.on('disconnect', function(){
delete clients[client.sessionId]
})
sendToClient("231489729578634289576", "hey dood!")
})
@thiagofm
Copy link

ty!

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