palavatv/palava-client — pull request #9 by thammi (2014-09-04 19:43:49+00:00)
Title: Datachannels

I started a branch with `DataChannel` support. I am not sure whether the API is the best approach.

To create a session with one TCP-like `DataChannel` with the label `chat` do something like this:

session = new palava.Session
roomId: room
channel: channel
dataChannels: {"chat": {ordered: true}}

session.on 'peer_channel_ready', (peer, name, channel) ->
if name == 'chat'
channel.on 'message', (data) ->
console.log "Incoming chat message:", data

channel.on 'close', () ->
console.log "DataChannel closed"

chat.send "Hello World!"

The configuration could also be moved to `Session.init()`.