在Opentok反应的母语,我怎么得到的各种活动一样连接客户信息,断开连接等

问题描述 投票:2回答:1

我已经搜索了很多,但找不到任何办法来查找,当用户连接,断开像opentok-react-native库各种回调,重新连接等。我甚至发现,他们所描述的各种事件OTSession的文件,但这些都不能正常工作。这些事件都得到所谓在一起。

视频通话是工作的罚款,但我想这取决于这些事件来执行各种动作

renderVideoView(data) {
console.log("rendering view view,, ", data);

return (
  <View
    style={{
      flex: 1,
      flexDirection: "row",
      backgroundColor: R.Colors.COLOR_VIDEO_BACKGROUND
    }}
  >
    <OTSession
      ref={ref => {
        this.OTSession = ref;
      }}
      connectionCreated={ console.log("connection created")}
      connectionDestroyed={ console.log("connection destroyed")}
      sessionConnected={ console.log("Client connect to a session")}
      sessionDisconnected={
        console.log("Client disConnect to a session")
      }
      sessionReconnected={() => console.log("session reconnected")}
      apiKey={this.apiKey}
      sessionId={data.sessionId}
      token={data.token}
    >
      <OTSubscriber style={{ width: "100%", height: "100%" }} />

      <View style={styles.publisherStyle}>
        <OTPublisher
          properties={{
            publishAudio: this.state.publishAudio,
            cameraPosition: this.state.cameraPosition,
            publishVideo: this.state.publishVideo
          }}
          style={{ width: 90, height: 107, padding: 2 }}
        />
      </View>

      {this.renderViewAtCenter()}
      {this.renderBottomView()}
      {this.renderTopView()}
    </OTSession>
  </View>
);}
react-native opentok
1个回答
1
投票

这里TokBox开发者传播者。

要通过OTSession组件设置的事件监听器,请用eventHandlers支撑,如下所示:

import React, { Component } from 'react';
import { View } from 'react-native';
import { OTSession, OTPublisher, OTSubscriber } from 'opentok-react-native';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.apiKey = '';
    this.sessionId = '';
    this.token = '';
    this.sessionEventHandlers = {
      connectionCreated: event =>  { 
          console.log("connection created", event);
      },
      connectionDestroyed: event =>  { 
          console.log("connection destroyed", event);
      },
      sessionConnected: event => { 
          console.log("Client connect to a session")
      },
      sessionDisconnected: event => {
        console.log("Client disConnect to a session")
      },
      sessionReconnected: event => {
        console.log("session reconnected")
      },
    };
  }

  render() {
    return (
      <View style={{ flex: 1, flexDirection: 'row' }}>
        <OTSession apiKey={this.apiKey} sessionId={this.sessionId} token={this.token} eventHandlers={this.sessionEventHandlers}>
          <OTPublisher style={{ width: 100, height: 100 }} />
          <OTSubscriber style={{ width: 100, height: 100 }} />
        </OTSession>
      </View>
    );
  }
}

我也已先行提起issue在回购改进为OTSession组件文档。

© www.soinside.com 2019 - 2024. All rights reserved.