如果我知道发布者sessionId,如何在opentok中手动订阅流?

时间:2016-05-15 18:20:59

标签: ruby-on-rails webrtc opentok tokbox

我通过此chatroulette on Rails using websockets编写了简单的example

subscribe event上我必须通过新令牌创建@partnerSession,还是我可以使用已生成的合作伙伴令牌?最重要的是:我如何手动获取合作伙伴流?我必须通过streamCreated事件存储所有流,然后使用合作伙伴sessionId获取一个吗?

  subscribe: (message) =>
    { sessionId, token } = message
    @partnerSession = OT.initSession API_KEY, sessionId

    # config partner session
    @partnerSession.on
      sessionConnected: (event) =>
        options = {
          insertMode: 'append',
          width: 400,
          height: 300
        }
        subscriber = @partnerSession.subscribe event.stream, 'subscriberContainer', options, (error) =>
          console.log error if error
          @notification "Have fun !!!!"
      sessionDisconnected: (event) =>
        @partnerSession.off # remove all event handlers
        @partnerSession = null
        @dispatcher.trigger 'find_partner' if @isPartnerNeeded
      streamDestroyed: (event) =>
        @partnerSession.disconnect()
    @partnerSession.connect API_KEY, token

1 个答案:

答案 0 :(得分:0)

我在名字fiels中传递了更多信息(@ partnerSession.sessionId),我知道这很讨厌