I needed something working quickly so went with signalR.
But I didn't like the client side syntax when compared to
socket.io….
So much so that I wrote a little wrapper making my client side code look like
socket.io
I only needed a bit of the functionality as you can see.
config = transport: 'longPolling'
connect = (name) ->
hub = $.connection[name]
emitQueue = []; clientId = null
$.connection.hub.start transport: config.transport, ->
clientId = @clientId
while item=emitQueue.shift()
hub.connect?()
clientId: -> clientId
on: (name, callback) ->
f = ->
callback.apply(hub, Array().slice.call(arguments))
hub[name] = f
callback() if name is 'connect' and clientId?
emit: ->
args = Array().slice.call arguments
name = args.shift()
if clientId
hub[name].apply hub, args
else
emitQueue.push name: name, args: args
connect: connect, config: config
socket = io.connect('command') # signalR's hub
socket.on 'hello', ->
socket.emit 'hello', from: 'client'
console.log "Received hello form server"