palavatv / palava

palava browser-to-browser video
https://palava.tv
30 stars 3 forks source link

Datachannels #6

Closed thammi closed 9 years ago

thammi commented 10 years ago

Issue by thammi Thursday Sep 04, 2014 at 19:43 GMT Originally opened as https://github.com/palavatv/palava-client/pull/9


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().


thammi included the following code: https://github.com/palavatv/palava-client/pull/9/commits

thammi commented 9 years ago

Was merged.