-
Notifications
You must be signed in to change notification settings - Fork 44
Server API
josephg edited this page Oct 6, 2011
·
3 revisions
server = connect browserChannel (client) ->
if client.address != '127.0.0.1' or client.appVersion != '10'
# calling client.stop() asks the client to stop trying to connect.
# The callback is called once the stop message has been sent.
client.stop -> client.close()
# Send arbitrary json messages to the client
client.send 'hi', (error) ->
# Callback is called when the client acknowledges its received the message
# Interface for receiving browserchannel string->string maps
client.on 'map', (data) ->
console.log data
# Interface for receiving JSON objects
client.on 'message', (data) ->
console.log data
setInterval (-> client.send ['yo dawg']), 3000
client.on 'close', ->
# Clean up
server.listen(4321)