🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

miniprogram-ar-rtmpc

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniprogram-ar-rtmpc - npm Package Compare versions

Comparing version
0.0.2
to
0.0.3
+2
-2
package.json
{
"name": "miniprogram-ar-rtmpc",
"version": "0.0.2",
"version": "0.0.3",
"description": "实时连麦小程序SDK",

@@ -10,3 +10,3 @@ "main": "index.js",

"author": "ar-team",
"license": "ISC",
"license": "MIT",
"devDependencies": {

@@ -13,0 +13,0 @@ "@babel/core": "^7.1.5",

+53
-374

@@ -7,6 +7,23 @@ # 实时连麦小程序SDK

1. 注册微信小程序,登录小程序后台获取微信小程序appid,appSecrert,修改类目审核(社交、教育、医疗、政务民生、金融,目前只有这些支持),配置socket合法域名wss://teameeting.anyrtc.io:9095
2. 前往平台注册账号获取开发者信息,创建应用并开通小程序服务
3. 开发-配置中开启“使用npm模块”,基础库选择2.4.0及以上,打开“不校验合法域名”、真机调试打开“调试”。集成moniprogram-ar-meet、moniprogram-ar-push、moniprogram-ar-play
### 设置小程序服务类别
登录[公众号平台](https://mp.weixin.qq.com),打开设置-基本设置-服务类目-详情-添加服务类目,目前小程序实时音视频支持这些[服务类目](https://developers.weixin.qq.com/miniprogram/dev/component/live-pusher.html),请选择其中一种。
![设置小程序服务类别](https://docs.anyrtc.io/assets/images/config_service.png)
### 开启实时音视频权限
登录[公众号平台](https://mp.weixin.qq.com),打开开发-接口设置,开启实时播放音视频流并开启实时录制音视频流。
![设置小程序服务类别](https://docs.anyrtc.io/assets/images/config_api_promise.png)
### 配置服务域名
登录[公众号平台](https://mp.weixin.qq.com),打开开发-开发设置-服务器域名-修改,配置服务域名白名单。
![设置小程序服务类别](https://docs.anyrtc.io/assets/images/config_domain.png)
### npm构建
打开开发者工具,打开设置-项目设置-勾选'使用npm模块',npm安装`moniprogram-ar-rtmpc`、`moniprogram-ar-push`、`moniprogram-ar-play`之后,点击工具-构建npm。
### 兼容情况
微信小程序基础库需要大于`1.7.0`,低版本需做兼容处理。
### 真机调试
开发者工具模拟器除特殊版本之外,不支持实时音视频功能,请使用真机调试。
# 使用说明

@@ -28,9 +45,11 @@

```
import { XcxGuestKit } from 'miniprogram-ar-rtmpc';
//创建实例
let wxrtmpc = new wxRTMPC();
let guest = new XcxGuestKit();
that.setData({
wxrtmpc: wxrtmpc
guest: guest
});
//初始化
wxrtmpc.initEngine(config.DEV_ID, config.APP_ID, config.APP_KEY, config.APP_TOKEN, config.APP_DOMAIN);
guest.initEngine(config.DEV_ID, config.APP_ID, config.APP_KEY, config.APP_TOKEN, config.APP_DOMAIN);

@@ -43,8 +62,24 @@ ```

//加入房间
wxrtmpc.joinRoom(roomId, userid, username,JSON.stringify({ userid }));
guest.joinRTCLine(roomId, userid, JSON.stringify({ userid }));
//加入房间成功回调
wxrtmpc.on("onJoinRoomOK", () => {
wx.showToast({
title: '加入房间成功',
});
guest.on("onJoinLineResult", (code, data) => {
if (code == 0) {
wx.showToast({
icon: 'success',
title: '加入房间成功',
});
}
else if (code == 605) {
wx.showToast({
icon: 'none',
title: '直播未开始',
});
}
else {
wx.showToast({
icon: 'none',
title: '加入房间失败: ' + code,
});
}
});

@@ -56,7 +91,9 @@ ```

//收到推流URL回调,将URL绑定到ar-push推流组件中,其他人将收到自己的视频
wxrtmpc.on("onGetPushUrl", (code, data) => {
guest.on("onGetPushUrl", (code, data) => {
console.log('onGetPushUrl', code, data);
if (code === 0) {//成功
that.setData({
pushURL: data.pushURL
xcxUserId: data.xcxUserId,
pushURL: data.pushURL,
arPushcomponent: that.selectComponent("#arPush"),
});

@@ -70,3 +107,2 @@ } else {

});
```

@@ -76,365 +112,8 @@ 4. 退出房间

```
wxrtmpc.leaveRoom();
guest.leaveRoom();
//自行路由跳转
```
# 完整代码
# Demo源码
WXML
```
<!--pages/room/room.wxml-->
<live-player wx:if="{{watchUrl && !onLine}}" style="width:100%;height:210px" id="rtcwatcher" src="{{watchUrl}}" autoplay binderror="onPlayError" bindstatechange="onPlay"></live-player>
<button wx:if="{{!onLine}}" type="button" bindtap="apply">连麦</button>
<ar-push
id="arPush"
width="{{pushWidth}}"
height="200"
coverImg="123"
enableAudio="{{enableAudio}}"
enableVideo="{{enableVideo}}"
pushURL="{{pushURL}}"
bindRoomEvent="handleRoomEvent">
</ar-push>
<button class="meet_btn" bindtap="pausePush">暂停推流</button>
<button class="meet_btn" bindtap="resumePush">恢复推流</button>
<button class="meet_btn" bindtap="switchCamera">切换前后摄像头</button>
<button class="" bindtap="enableCamera">开关摄像头 :: 当前状态{{enableVideo ? '开' : '关'}}</button>
<button class="" bindtap="enableMicphone">开关麦克风 :: 当前状态{{enableAudio ? '开' : '关'}}</button>
<!-- ar拉流组件,view包裹可自定义样式-->
<view wx:for="{{members}}" wx:key="index">
<ar-play
id="{{item.pubID}}-play"
pubID="{{item.pubID}}"
width="{{item.width}}"
height="{{item.height}}"
playURL="{{item.playURL}}"
bindPlayStatus="handlePlayStatus">
</ar-play>
<button class="meet_btn" data-id="{{item.pubID}}" bindtap="pause">暂停</button>
<button class="meet_btn" data-id="{{item.pubID}}" bindtap="play">播放</button>
<button class="meet_btn" data-id="{{item.pubID}}" bindtap="full">全屏</button>
</view>
<button wx:if="{{onLine}}" type="button" bindtap="hangup">挂断</button>
```
JS
```
var wxRTMPC = require('../../lib/RTMPCXcxKit.js').default;
const config = require('../../config.js');
const _windowWidth = wx.getSystemInfoSync().windowWidth;
// pages/room/room.js
Page({
/**
* 页面的初始数据
*/
data: {
onLine: false,
watchUrl: '',//游客默认观看主播流
userID: '',
arPusherComponent: null,
wxrtmpc: null,
pushURL: '',
pushWidth: _windowWidth,
enableAudio: false,
enableVideo: true,
members: [],
},
onScreen () {
wx.setKeepScreenOn({
keepScreenOn: true
})
},
offScreen () {
wx.setKeepScreenOn({
keepScreenOn: false
})
},
//停止推流
pausePush() {
arPusherComponent: this.selectComponent('#arPush') && this.data.arPusherComponent.pause();
},
//恢复推流
resumePush() {
arPusherComponent: this.selectComponent('#arPush') && this.data.arPusherComponent.resume();
},
//切换摄像头
switchCamera() {
arPusherComponent: this.selectComponent('#arPush') && this.data.arPusherComponent.switchCamera();
},
//打开/关闭摄像头
enableCamera() {
this.setData({
enableVideo: !this.data.enableVideo
});
},
//打开/关闭麦克风
enableMicphone() {
this.setData({
enableAudio: !this.data.enableAudio
});
},
//暂停远程人员音视频流
pause(e) {
let that = this;
let data = e.currentTarget.dataset;
//参考 https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.pause.html
that.selectComponent(`#${data.id}-play`).pause({
complete: res => {
console.log('selectComponent pause', res);
}
});
},
//播放远程人员音视频流
play(e) {
let that = this;
let data = e.currentTarget.dataset;
//参考 https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.play.html
that.selectComponent(`#${data.id}-play`).play({
complete: res => {
console.log('selectComponent pause', res);
}
});
},
//使远程人员音视频流全屏
full(e) {
let that = this;
let data = e.currentTarget.dataset;
//参考 https://developers.weixin.qq.com/miniprogram/dev/api/media/live/LivePlayerContext.requestFullScreen.html
that.selectComponent(`#${data.id}-play`).requestFullScreen({
direction: 90,
complete: res => {
console.log('selectComponent pause', res);
}
});
//此处由于只做演示,所以2秒之后结束全屏
setTimeout(() => {
that.selectComponent(`#${data.id}-play`).exitFullScreen({
complete: res => {
console.log('selectComponent pause', res);
}
});
}, 2000);
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that = this;
let roomId = '' + options.roomid;
let wxrtmpc = new wxRTMPC();
that.onScreen();
that.setData({
watchUrl: options.rtmpUrl,
wxrtmpc: wxrtmpc,
arPusherComponent: that.selectComponent('#arPush')
});
wxrtmpc.initEngine(config.DEV_ID, config.APP_ID, config.APP_KEY, config.APP_TOKEN, config.APP_DOMAIN);
let userid = '' + parseInt(Math.random() * 10000);
wxrtmpc.joinRTCLine(roomId, userid, JSON.stringify({ userid }));
//连接RTC结果回调
wxrtmpc.on("onRTCJoinLineResult", (code, data) => {
console.log('onRTCJoinLineResult', code, data);
});
//申请连线结果
wxrtmpc.on("onRTCApplyLineResult", (code, id) => {
console.log('onRTCApplyLineResult', code, id);
if (code === 0) {
that.setData({
onLine: true
});
}
});
//连线被挂断
wxrtmpc.on("onRTCHangupLine", () => {
console.log('onRTCHangupLine');
that.setData({
onLine: false
});
});
wxrtmpc.on("onGetPushUrl", (code, data) => {
if (code === 0) {//成功
that.setData({
pushURL: data.pushURL
});
} else {
wx.showToast({
icon: 'none',
title: '获取房间签名失败',
});
}
});
//直播人员列表
wxrtmpc.on("onRTCMemberListNotify", (nTotal, RoomID, RoomSvrID) => {
console.log('onRTCMemberListNotify', nTotal, RoomID, RoomSvrID);
});
//直播开始
wxrtmpc.on("onRTCLiveStart", () => {
console.log('onRTCLiveStart');
});
//直播暂时停止
wxrtmpc.on("onRTCLiveStop", () => {
console.log('onRTCLiveStop');
that.backIndex();
});
//直播结束
wxrtmpc.on("onRTCLineLeave", () => {
console.log('onRTCLineLeave');
});
},
backIndex () {
wx.navigateBack();
},
//申请连线
apply() {
this.data.wxrtmpc.applyRTCLine(JSON.stringify({ nickName: 'hello' }));
},
//挂断连线
hangup () {
this.data.wxrtmpc.hangupRTCLine();
this.backIndex();
},
//监听房间事件
handleRoomEvent (e) {
let that = this;
let data = e.detail;
console.log('handleRoomEvent', data);
let members = that.data.members;
switch (data.tag) {
case "MemberJoin":
let newMember = data.detail;
newMember.map(item => {
let nitem = Object.assign({}, item, {
width: 100,
height: 100
});
members.push(nitem);
});
that.setData({
members: members
});
break;
case "MemberLeave":
let leaveUsers = data.detail;
members.map((item, index) => {
leaveUsers.map((i, n) => {
if (i.pubID === item.pubID) {
members.splice(index, 1);
}
});
});
that.setData({
members: members
});
break;
case "PushError":
//重新进会
break;
}
},
//监听播放状态
handlePlayStatus (e) {
let that = this;
let data = e.detail;
//错误码参考 https://developers.weixin.qq.com/miniprogram/dev/component/live-player.html
console.log('handlePlayStatus', `pubID为 ${data.pubID} 的播放状态为 ${data.code}`);
},
//未连线时播放主播rtmp流状态
onPlay (e) {
console.log('onPlay', e);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
console.log('onHide');
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
console.log('onUnload');
this.onScreen();
//断开RTC连接并释放资源
this.data.wxrtmpc.clear();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
```
[github](https://github.com/anyrtc/anyRTC-Miniprogram)

@@ -8,7 +8,10 @@ import EventEmitter from './lib/emitter.js';

// this.url = 'ws://teameeting.anyrtc.io:9095';
// this.url = 'ws://pro.anyrtc.io:9095';
this.url = 'ws://192.168.199.219:9095';
this.url = 'www.anyrtc.io';
this.urlSuffix = '/ws';
this.svrUrl = 'wss://' + this.url + this.urlSuffix;
this.webSocket = null;
this.userToekn = '';
this.useNewApi = false;//是否使用Token验证
//所在房间

@@ -53,3 +56,3 @@ this.anyrtcId = '';

if (that.webSocket == null) {
var strUrl = that.url + "/?Type=live_g_wx&UserId=" + that.devId + "&AppId=" + that.appId + "&AppKey=" + that.appKey + "&Token=" + that.appToken;
var strUrl = that.svrUrl + "/?Type=live_g_wx&UserId=" + that.devId + "&AppId=" + that.appId + "&AppKey=" + that.appKey + "&Token=" + that.appToken;

@@ -59,3 +62,3 @@ that.webSocket = wx.connectSocket({

success: function (res) {
that.Logcat('connectSocket success', res)
that.Logcat('connectSocket success', res);
},

@@ -86,3 +89,4 @@ fail: function (error) {

objMsg["UserData"] = that.userData;
that.Logcat(objMsg)
objMsg["XcxLine"] = true;
that.Logcat(objMsg);
that.doSendMessage(JSON.stringify(objMsg));

@@ -230,6 +234,6 @@

that.webSocket.onClose = function () {
that.webSocket.onClose(function () {
that.Logcat('webSocket onClose')
that.webSocket = null;
};
});
}

@@ -327,14 +331,3 @@ }

NotifyError(methodName, errMsg) {
let that = this;
/**
* @errorMethodName 错误的方法名称
* @errorMethodMsg 错误消息提示
*/
that.emit('onSDKError', methodName, {
msg: errMsg
});
}
/**
/**
* 配置开发者信息

@@ -351,16 +344,12 @@ * @params strDeveloperId 开发者id

if (typeof strDeveloperId !== "string") {
that.NotifyError('initEngine', 'type of strDeveloperId is not string.');
return false;
throw new Error('[initEngine] strDeveloperId must be string.');
}
if (typeof strAppId !== "string") {
that.NotifyError('initEngine', 'type of strAppId is not string.');
return false;
throw new Error('[initEngine] strAppId must be string.');
}
if (typeof strAppKey !== "string") {
that.NotifyError('initEngine', 'type of strAppKey is not string.');
return false;
throw new Error('[initEngine] strAppKey must be string.');
}
if (typeof strAppToken !== "string") {
that.NotifyError('initEngine', 'type of strAppToken is not string.');
return false;
throw new Error('[initEngine] strAppToken must be string.');
}

@@ -372,35 +361,63 @@

that.appToken = strAppToken;
that.useNewApi = false;
}
/**
* 配置私有云
* @params strAddress 私有云服务地址
* @params nPort 私有云服务端口
* API说明 配置私有云信息。当使用私有云时才需要调用该接口配置,默认不需要配置。
**/
configServer(strAddress, nPort) {
var that = this;
* 配置应用token
* @params strUserToken 用户token
* API说明 配置开发者信息。
**/
setUserToken(strUserToken) {
var that = this;
if (typeof strAddress !== "string") {
that.NotifyError('configServerForPriCloud', 'type of strAddress is not string.');
return false;
}
if (typeof strUserToken !== "string") {
throw new Error('[setUserToken] strUserToken must be string.');
}
that.userToekn = strUserToken;
}
var ishttps = 'https:' == document.location.protocol ? true : false;
if (ishttps) {
if (nPort) {
that.url = "wss://" + strAddress + ":" + nPort;
} else {
that.url = "wss://" + strAddress;
}
} else {
if (nPort) {
that.url = "ws://" + strAddress + ":" + nPort;
} else {
that.url = "ws://" + strAddress;
}
}
}
/**
* 配置开发者应用信息
* @params strAppId 应用id
* @params strAppToken 应用的appToken
* API说明 配置开发者信息
**/
initAppInfo(strAppId, strAppToken) {
var that = this;
if (typeof strAppId !== "string") {
throw new Error('[initAppInfo] strAppId must be string.');
}
if (typeof strAppToken !== "string") {
throw new Error('[initAppInfo] strAppToken must be string.');
}
that.appId = strAppId;
that.appToken = strAppToken;
that.useNewApi = true;
}
/**
* 配置服务
* @params strAddress 配置服务地址
* @params nPort 配置服务端口
* API说明 配置服务信息。默认不需要配置。
**/
configServer (strAddress, nPort) {
var that = this;
if (typeof strAddress !== "string") {
throw new Error('[configServer] strAddress must be string.');
}
that.url = strAddress;
if (nPort) {
that.svrUrl = "ws://" + that.url + ':' + nPort;
} else {
that.svrUrl = "wss://" + that.url + that.urlSuffix;
}
}
/**
* 加入RTC连线

@@ -415,9 +432,3 @@ * @params strAnyrtcId 在开发者业务系统中保持唯一标识(理解为房间号)

if (typeof strAnyrtcId !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strAnyrtcId is not string.');
return false;
throw new Error('[joinRTCLine] strAnyrtcId must be string.');
}

@@ -427,9 +438,3 @@ that.anyrtcId = strAnyrtcId;

if (typeof strUserId !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strUserId is not string.');
return false;
throw new Error('[joinRTCLine] strUserId must be string.');
}

@@ -439,19 +444,6 @@ that.userId = strUserId;

if (typeof strUserData !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strUserData is not string.');
return false;
throw new Error('[joinRTCLine] strUserData must be string.');
} else {
if (that.strlen(strUserData) > 512) {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'strUserData is out of length.');
return false;
throw new Error('[joinRTCLine] strUserData is out of length.');
}

@@ -461,2 +453,3 @@ }

///-------------------------------
that.Logcat("Do joinRTC ......");

@@ -463,0 +456,0 @@ that.doInitWSocket();

@@ -8,7 +8,10 @@ import EventEmitter from './lib/emitter.js';

// this.url = 'ws://teameeting.anyrtc.io:9095';
// this.url = 'ws://pro.anyrtc.io:9095';
this.url = 'ws://192.168.199.219:9095';
this.url = 'www.anyrtc.io';
this.urlSuffix = '/ws';
this.svrUrl = 'wss://' + this.url + this.urlSuffix;
this.webSocket = null;
this.userToekn = '';
this.useNewApi = false;//是否使用Token验证
//所在房间

@@ -55,3 +58,3 @@ this.anyrtcId = '';

if (that.webSocket == null) {
var strUrl = that.url + "/?Type=live_h_wx&UserId=" + that.devId + "&AppId=" + that.appId + "&AppKey=" + that.appKey + "&Token=" + that.appToken;
var strUrl = that.svrUrl + "/?Type=live_h_wx&UserId=" + that.devId + "&AppId=" + that.appId + "&AppKey=" + that.appKey + "&Token=" + that.appToken;

@@ -92,3 +95,3 @@ that.webSocket = wx.connectSocket({

objMsg["VHeight"] = 640;//视频高度 int 型
objMsg["VBitrate"] = 512;//视频带宽 int 型
objMsg["XcxLine"] = true;
that.Logcat(objMsg);

@@ -237,6 +240,6 @@ that.doSendMessage(JSON.stringify(objMsg));

that.webSocket.onClose = function () {
that.webSocket.onClose(function () {
that.Logcat('webSocket onClose')
that.webSocket = null;
};
});
}

@@ -334,14 +337,3 @@ }

NotifyError(methodName, errMsg) {
let that = this;
/**
* @errorMethodName 错误的方法名称
* @errorMethodMsg 错误消息提示
*/
that.emit('onSDKError', methodName, {
msg: errMsg
});
}
/**
/**
* 配置开发者信息

@@ -358,16 +350,12 @@ * @params strDeveloperId 开发者id

if (typeof strDeveloperId !== "string") {
that.NotifyError('initEngine', 'type of strDeveloperId is not string.');
return false;
throw new Error('[initEngine] strDeveloperId must be string.');
}
if (typeof strAppId !== "string") {
that.NotifyError('initEngine', 'type of strAppId is not string.');
return false;
throw new Error('[initEngine] strAppId must be string.');
}
if (typeof strAppKey !== "string") {
that.NotifyError('initEngine', 'type of strAppKey is not string.');
return false;
throw new Error('[initEngine] strAppKey must be string.');
}
if (typeof strAppToken !== "string") {
that.NotifyError('initEngine', 'type of strAppToken is not string.');
return false;
throw new Error('[initEngine] strAppToken must be string.');
}

@@ -379,35 +367,63 @@

that.appToken = strAppToken;
that.useNewApi = false;
}
/**
* 配置私有云
* @params strAddress 私有云服务地址
* @params nPort 私有云服务端口
* API说明 配置私有云信息。当使用私有云时才需要调用该接口配置,默认不需要配置。
**/
configServer(strAddress, nPort) {
var that = this;
* 配置应用token
* @params strUserToken 用户token
* API说明 配置开发者信息。
**/
setUserToken(strUserToken) {
var that = this;
if (typeof strAddress !== "string") {
that.NotifyError('configServerForPriCloud', 'type of strAddress is not string.');
return false;
}
if (typeof strUserToken !== "string") {
throw new Error('[setUserToken] strUserToken must be string.');
}
that.userToekn = strUserToken;
}
var ishttps = 'https:' == document.location.protocol ? true : false;
if (ishttps) {
if (nPort) {
that.url = "wss://" + strAddress + ":" + nPort;
} else {
that.url = "wss://" + strAddress;
}
} else {
if (nPort) {
that.url = "ws://" + strAddress + ":" + nPort;
} else {
that.url = "ws://" + strAddress;
}
}
}
/**
* 配置开发者应用信息
* @params strAppId 应用id
* @params strAppToken 应用的appToken
* API说明 配置开发者信息
**/
initAppInfo(strAppId, strAppToken) {
var that = this;
if (typeof strAppId !== "string") {
throw new Error('[initAppInfo] strAppId must be string.');
}
if (typeof strAppToken !== "string") {
throw new Error('[initAppInfo] strAppToken must be string.');
}
that.appId = strAppId;
that.appToken = strAppToken;
that.useNewApi = true;
}
/**
* 配置服务
* @params strAddress 配置服务地址
* @params nPort 配置服务端口
* API说明 配置服务信息。默认不需要配置。
**/
configServer (strAddress, nPort) {
var that = this;
if (typeof strAddress !== "string") {
throw new Error('[configServer] strAddress must be string.');
}
that.url = strAddress;
if (nPort) {
that.svrUrl = "ws://" + that.url + ':' + nPort;
} else {
that.svrUrl = "wss://" + that.url + that.urlSuffix;
}
}
/**
* 加入RTC连线

@@ -424,9 +440,3 @@ * @params strAnyrtcId 在开发者业务系统中保持唯一标识(理解为房间号)

if (typeof strAnyrtcId !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strAnyrtcId is not string.');
return false;
throw new Error('[joinRTCLine] strAnyrtcId must be string.');
}

@@ -436,9 +446,3 @@ that.anyrtcId = strAnyrtcId;

if (typeof strPushUrl !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strPushUrl is not string.');
return false;
throw new Error('[joinRTCLine] strPushUrl must be string.');
}

@@ -448,9 +452,3 @@ that.pushUrl = strPushUrl;

if (typeof strUserId !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strUserId is not string.');
return false;
throw new Error('[joinRTCLine] strUserId must be string.');
}

@@ -460,19 +458,6 @@ that.userId = strUserId;

if (typeof strUserData !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strUserData is not string.');
return false;
throw new Error('[joinRTCLine] strUserData must be string.');
} else {
if (that.strlen(strUserData) > 512) {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'strUserData is out of length.');
return false;
throw new Error('[joinRTCLine] strUserData is out of length.');
}

@@ -483,19 +468,6 @@ }

if (typeof strLiveInfo !== "string") {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'type of strLiveInfo is not string.');
return false;
throw new Error('[joinRTCLine] strLiveInfo must be string.');
} else {
if (that.strlen(strLiveInfo) > 512) {
/**
* 创建RTC服务连接结果
* nCode 错误码 4 参数非法
**/
that.emit('onJoinLineResult', 4); // 参数非法
that.NotifyError('joinRTCLine', 'strLiveInfo is out of length.');
return false;
throw new Error('[joinRTCLine] strLiveInfo must be string.');
}

@@ -515,2 +487,3 @@ }

var that = this;
if (!strPeerId) return;
var objMsg = {};

@@ -517,0 +490,0 @@ objMsg["Cmd"] = "AcceptApply";

var XcxHosterKit = require('./hoster.js');
var XcxGuestKit = require('./guest.js');
// exports.XcxHosterKit = XcxHosterKit;
// exports.XcxGuestKit = XcxGuestKit;
module.exports = {
XcxHosterKit,
XcxGuestKit
}
};