设置代理服务器

11-set_proxy_server

设置代理服务器

  1. 通过 getTRTCCloudInstance 获取 TRTCCloud 实例。注意:v3.1.3+ 支持
import { TUICallEngine } from 'tuicall-engine-webrtc';
const options = {
  SDKAppID: 0,
  tim: tim,
};
const tuiCallEngine = TUICallEngine.createInstance(options);
const trtcCloud = tuiCallEngine.getTRTCCloudInstance();
  1. 通过 TRTCCloud 实例调用 callExperimentalAPI 完成代理服务器的设置(注意:需要在通话前调用)。具体如下:
trtcCloud.callExperimentalAPI(JSON.stringify({
   api: 'setNetworkProxy',
   params: {
      websocketProxy: 'wss://proxy.example.com/ws/',
      turnServer: [{
         url: '14.3.3.3:3478',
         username: 'turn',
         credential: 'turn',
      }],
      iceTransportPolicy: 'relay',
   },
}));