邀请者的账号 account id
该操作的附加信息,透传给其他人
接受邀请后,是否直接加入频道。默认为 true
频道 id
接受邀请后,加入频道的操作附加信息,将在加入频道通知中带给其他频道成员
是否存入离线消息。默认 false
邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该 requestId
接受邀请后,自己在频道中对应的uid。大于零有效,无效时服务器会分配随机唯一的uid
呼叫: 创建一个频道, 己方加入,并邀请对方加入频道
注: 组合接口, 相当于调用 signalingCreateAndJoin 后, 调用 signalingInvite.
nim.signalingCall({
type: 1,
channelName: 'audio-call-' + Date.now(),
account: 'user1',
requestId: 'req-' + Date.now(),
pushInfo: {
needPush: true,
pushTitle: '语音通话',
pushContent: '您有一个语音通话邀请'
}
}).then(function(channel) {
console.log('呼叫成功', channel)
}).catch(function(err) {
console.log('呼叫失败', err)
})
受邀请者的账号 account id
该操作的附加信息,透传给受邀请者
频道名称
扩展字段
是否存入离线消息。默认 false
推送属性
邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该 requestId
频道类型, 通话类型 1: 音频; 2: 视频; 3: 其他
自己在频道中对应的uid,大于零有效,无效时服务器会分配随机唯一的uid
呼叫加入音视频频道: 创建一个频道, 己方加入,并邀请对方加入音视频的频道
注: 组合接口, 比 signalingCall 多了云信 G2 音视频相关的参数
nim.signalingCallEx({
type: 2,
channelName: 'video-call-' + Date.now(),
account: 'user1',
requestId: 'req-' + Date.now(),
nertcChannelName: 'rtc-room-123',
pushInfo: {
needPush: true,
pushTitle: '视频通话',
pushContent: '您有一个视频通话邀请'
}
}).then(function(channel) {
console.log('呼叫成功', channel)
}).catch(function(err) {
console.log('呼叫失败', err)
})
受邀请者的账号 account id
该操作的附加信息,透传给受邀请者
频道名称
扩展字段
云信 G2-RTC 的房间名,加入频道时 sdk 会携带这个参数, 再返回对应的 token
云信G2-RTC加入房间的请求参数,推荐传入 JSON 序列化字符串
云信 G2-RTC 的 token 的有效期,表示 token 的过期时间,单位秒,选填,默认10分钟
是否存入离线消息。默认 false
推送属性
邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该 requestId
频道类型, 通话类型 1: 音频; 2: 视频; 3: 其他
自己在频道中对应的uid,大于零有效,无效时服务器会分配随机唯一的uid
取消邀请
nim.signalingCancel({
channelId: 'channel-123',
account: 'user1',
requestId: 'req-123'
}).then(function() {
console.log('取消邀请成功')
}).catch(function(err) {
console.log('取消邀请失败', err)
})
受邀请者的账号 account id
该操作的附加信息,透传给受邀请者
频道 id
是否存入离线消息。默认 false
邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该 requestId
关闭频道
nim.signalingClose({
channelId: 'channel-123',
offlineEnabled: true
}).then(function() {
console.log('关闭频道成功')
}).catch(function(err) {
console.log('关闭频道失败', err)
})
该操作的附加信息,透传给其他人
频道 id
是否存入离线消息。默认 false
发送自定义信令
nim.signalingControl({
channelId: 'channel-123',
attachExt: JSON.stringify({ action: 'mute-video' })
}).then(function() {
console.log('发送自定义信令成功')
}).catch(function(err) {
console.log('发送自定义信令失败', err)
})
要通知的目标账号(account id)。如果不传则通知所有人
该操作的附加信息,透传给其他人
频道 id
创建频道
nim.signalingCreate({
type: 2,
channelName: 'my-channel-' + Date.now(),
ext: JSON.stringify({ roomType: 'meeting' })
}).then(function(channel) {
console.log('创建频道成功', channel)
}).catch(function(err) {
console.log('创建频道失败', err)
})
频道名称
扩展字段
频道类型, 通话类型 1: 音频; 2: 视频; 3: 其他
如果不存在房间, 则创建一个频道,并且己方加入. 如果已存在频道,则己方直接加入
注: 组合接口, 相当于调用 signalingCreate 后, 调用 signalingJoin.
nim.signalingCreateAndJoin({
type: 2,
channelName: 'room-' + Date.now()
}).then(function(channel) {
console.log('创建并加入频道成功', channel)
}).catch(function(err) {
console.log('创建并加入频道失败', err)
})
该操作的附加信息,透传给受邀请者
频道名称
扩展字段
是否存入离线消息。默认 false
频道类型, 通话类型 1: 音频; 2: 视频; 3: 其他
自己在频道中对应的uid,大于零有效,无效时服务器会分配随机唯一的uid
延长频道的有效期
nim.signalingDelay({
channelId: 'channel-123'
}).then(function(channel) {
console.log('延长频道有效期成功', channel)
}).catch(function(err) {
console.log('延长频道有效期失败', err)
})
频道id,唯一标识
查询频道信息. 根据 channelName 查询房间信息
nim.signalingGetChannelInfo({
channelName: 'my-channel-123'
}).then(function(channel) {
console.log('查询频道信息成功', channel)
console.log('频道成员', channel.members)
}).catch(function(err) {
console.log('查询频道信息失败', err)
})
频道名
邀请某人进入频道
nim.signalingInvite({
channelId: 'channel-123',
account: 'user1',
requestId: 'req-' + Date.now(),
pushInfo: {
needPush: true,
pushContent: '邀请您加入通话'
}
}).then(function() {
console.log('邀请成功')
}).catch(function(err) {
console.log('邀请失败', err)
})
受邀请者的账号 account id
该操作的附加信息,透传给受邀请者
频道 id
是否存入离线消息。默认 false
推送属性
邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该 requestId
加入频道
nim.signalingJoin({
channelId: 'channel-123'
}).then(function(channel) {
console.log('加入频道成功', channel)
}).catch(function(err) {
console.log('加入频道失败', err)
})
该操作的附加信息,透传给其他人
频道 id
是否存入离线消息。默认 false
自己在频道中对应的uid,大于零有效,无效时服务器会分配随机唯一的uid
加入频道并接受邀请。该接口实际为组合接口,等同于先调用加入频道,成功后再调用接受邀请接口。
nim.signalingJoinAndAccept({
channelId: 'channel-123',
account: 'inviter1',
requestId: 'req-123',
nertcChannelName: 'rtc-room-123'
}).then(function() {
console.log('加入频道并接受邀请成功')
}).catch(function(err) {
console.log('加入频道并接受邀请失败', err)
})
对方accid,必须
该操作的附加信息,透传给其他人
频道 id
云信G2-RTC的房间名,加入频道请求时携带,则会返回token
云信G2-RTC加入房间的请求参数,推荐传入 JSON 序列化字符串
云信G2-RTC的token的有效期,表示token的过期时间,单位秒,选填,默认10分钟
是否存离线通知,默认false
必须,邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该requestId
自己在频道中对应的uid,大于零有效,无效时服务器会分配随机唯一的uid
离开频道
nim.signalingLeave({
channelId: 'channel-123'
}).then(function() {
console.log('离开频道成功')
}).catch(function(err) {
console.log('离开频道失败', err)
})
该操作的附加信息,透传给其他人
频道 id
是否存入离线消息。默认 false
标记信令消息已收到, 下次不会在离线同步中收到此消息
nim.signalingMarkMsgRead({
msgid: ['msg-1', 'msg-2']
}).then(function() {
console.log('标记信令消息已读成功')
}).catch(function(err) {
console.log('标记信令消息已读失败', err)
})
需要标记的已读的信令消息 id
拒绝进入频道的邀请
nim.signalingReject({
channelId: 'channel-123',
account: 'inviter1',
requestId: 'req-123',
attachExt: JSON.stringify({ reason: '忙碌中' })
}).then(function() {
console.log('拒绝邀请成功')
}).catch(function(err) {
console.log('拒绝邀请失败', err)
})
邀请者的账号 account id
该操作的附加信息,透传给其他人
频道 id
是否存入离线消息。默认 false
邀请者邀请的请求id,需要邀请者填写,之后取消邀请、拒绝、接受需要复用该 requestId
接受进入频道的邀请
示例