new TSignaling(options) → {Object}
腾讯云 Web 信令 SDK 入口类。
                接入前,您需要在 云通信控制台 中创建一个云通信应用,并取得 SDKAppID。
Example
let options = {
  SDKAppID: 0 // 接入时需要将0替换为您的云通信应用的 SDKAppID
};
let tsignaling = new TSignaling(options);
            Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                  Object | 
                     配置 Properties
  | 
                
Returns:
SDK 实例
- Type
 - Object
 
Methods
setLogLevel(level)
设置日志级别,低于 level 的日志将不会输出。
Example
tsignaling.setLogLevel(0);
          Parameters:
| Name | Type | Description | 
|---|---|---|
level | 
                Number | 
                   日志级别 
  | 
              
login(options) → {Promise}
登录
Example
let promise = tsignaling.login({userID: 'your userID', userSig: 'your userSig'});
promise.then(function(imResponse) {
  console.log(imResponse.data); // 登录成功
  if (imResponse.data.repeatLogin === true) {
    // 标识账号已登录,本次登录操作为重复登录
    console.log(imResponse.data.errorInfo);
  }
}).catch(function(imError) {
  console.warn('login error:', imError); // 登录失败的相关信息
});
          Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   登录配置 Properties
  | 
              
Returns:
- Type
 - Promise
 
logout() → {Promise}
登出,通常在切换帐号的时候调用,清除登录态以及内存中的所有数据。
Example
let promise = tsignaling.logout();
promise.then(function(imResponse) {
  console.log(imResponse.data); // 登出成功
}).catch(function(imError) {
  console.warn('logout error:', imError);
});
          Returns:
- Type
 - Promise
 
off(eventName, handler)
解除监听事件。
Example
let onTextMessageReceived = function(event) {
  event.data.forEach(function(message) {
    console.log('demo ' + (message.from || message.nick) + ' : ', message.payload.text);
  });
};
tsignaling.off(TSignaling.EVENT.TEXT_MESSAGE_RECEIVED, onTextMessageReceived);
          Parameters:
| Name | Type | Description | 
|---|---|---|
eventName | 
                String | 
                   事件名称。所有的事件名称都存放在   | 
              
handler | 
                function | 
                   处理事件的方法。  | 
              
joinGroup(groupID) → {Promise}
加入群组
Example
let promise = tsignaling.joinGroup('group1');
promise.then(function(imResponse) {
  switch (imResponse.data.status) {
    case TSignaling.TYPES.JOIN_STATUS_WAIT_APPROVAL: // 等待管理员同意
      break;
    case TSignaling.TYPES.JOIN_STATUS_SUCCESS: // 加群成功
      console.log(imResponse.data.group); // 加入的群组资料
      break;
    case TSignaling.TYPES.JOIN_STATUS_ALREADY_IN_GROUP: // 已经在群中
      break;
    default:
      break;
  }
}).catch(function(imError){
  console.warn('joinGroup error:', imError); // 申请加群失败的相关信息
});
          Parameters:
| Name | Type | Description | 
|---|---|---|
groupID | 
                String | 
                   群组 ID  | 
              
Returns:
- Type
 - Promise
 
quitGroup(groupID) → {Promise}
退出群组
Example
let promise = tsignaling.quitGroup('group1');
promise.then(function(imResponse) {
  console.log(imResponse.data.groupID); // 退出成功的群 ID
}).catch(function(imError){
  console.warn('quitGroup error:', imError); // 退出群组失败的相关信息
});
          Parameters:
| Name | Type | Description | 
|---|---|---|
groupID | 
                String | 
                   群组 ID  | 
              
Returns:
- Type
 - Promise
 
sendTextMessage(options) → {Promise}
发送文本消息
Example
let promise = tsignaling.sendTextMessage({
  to: 'AV1',
  groupFlag: true,
  priority: TSignaling.TYPES.MSG_PRIORITY_NORMAL,
  text: 'hello from TSignaling'
});
promise.then(function(imResponse) {
  console.log('demo sendTextMessage OK', imResponse);
}).catch(function(imError) {
  console.log('demo sendTextMessage failed', imError);
});
          Parameters:
| Name | Type | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   消息参数 Properties
  | 
              
Returns:
- Type
 - Promise
 
sendCustomMessage(options) → {Promise}
发送自定义消息
Example
let promise = tsignaling.sendCustomMessage({
  to: 'AV1',
  groupFlag: true,
  priority:TSignaling.TYPES.MSG_PRIORITY_NORMAL,
  data: 'dianzan', // 用于标识该消息是点赞类型的自定义消息
  description: '',
  extension: ''
});
promise.then(function(imResponse) {
  console.log('demo sendCustomMessage OK', imResponse);
}).catch(function(imError) {
  console.log('demo sendCustomMessage failed', imError);
});
          Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   消息参数 Properties
  | 
              
Returns:
- Type
 - Promise
 
invite(options) → {Promise}
邀请单个人
Example
tsignaling.invite({
  userID: 'user1',
  data: JSON.stringify({content: 'xxx', platform: 'xxx'})
}).then(function(res) {
  console.log('demo invite OK', res);
}).catch(function(error) {
  console.log('demo invite failed', error.code, error.message);
});
          Parameters:
| Name | Type | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   邀请配置 Properties
  | 
              
Returns:
- Type
 - Promise
 
inviteInGroup(options) → {Promise}
邀请群内的某些人
Example
tsignaling.inviteInGroup({
  groupID: 'AV1',
  inviteeList: ['user1', 'user2'],
  data: JSON.stringify({content: 'xxx', platform: 'xxx'}),
  timeout: 10
}).then(function(res) {
  console.log('demo inviteInGroup OK', res);
}).catch(function(error) {
  console.log('demo inviteInGroup failed', error.code, error.message);
});
          Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   邀请配置 Properties
  | 
              
Returns:
- Type
 - Promise
 
cancel(options) → {Promise}
邀请发起者取消邀请
Example
tsignaling.cancel({
  inviteID: '38897dbf-ecd4-4b59-a132-bc31529a2b18'
}).then(function(res) {
  console.log('demo cancel OK', res);
}).catch(function(error) {
  console.log('demo cancel failed', error.code, error.message);
});
          Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   配置 Properties
  | 
              
Returns:
- Type
 - Promise
 
accept(options) → {Promise}
被邀请人接受邀请
Example
tsignaling.accept({
  inviteID: '38897dbf-ecd4-4b59-a132-bc31529a2b18'
}).then(function(res) {
  console.log('demo accept OK', res);
}).catch(function(error) {
  console.log('demo accept failed', error.code, error.message);
});
          Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   配置 Properties
  | 
              
Returns:
- Type
 - Promise
 
reject(options) → {Promise}
被邀请人拒绝邀请
Example
tsignaling.reject({
  inviteID: '38897dbf-ecd4-4b59-a132-bc31529a2b18'
}).then(function(res) {
  console.log('demo reject OK', res);
}).catch(function(error) {
  console.log('demo reject failed', error.code, error.message);
});
          Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
                Object | 
                   配置 Properties
  | 
              
Returns:
- Type
 - Promise