# Multiple audio and video conversations
Used to achieve Weixin Mini Program in the multi-person audio and video dialogue function.
# Request to open
Weixin Mini Program management background, "development" - "interface settings" in the self-opening of the component permissions.Related interfaces wx.joinVoIPChat and components voip-room .
# Calling Process
Developers only need to provide a unique room identifier to join a specified room. A user who enters the same unique identifier will enter the same room.To ensure that thegroupIdof the front-end incoming is credible, the wx.joinVoIPChat interface requires incoming signatures.See Signature Algorithm .When the video room is added, the member screen can be displayed in combination with the voip-room component.
# Front-end Interface
- Create / join room: wx.joinVoIPChat
- Leaving the room: wx.exitVoIPChat
- Update room microphone / headset mute settings: wx.updateVoIPChatMuteConfig
- Listening room member change: wx.onVoIPChatMembersChanged
- wx.on VoIP Chat Speakers Changed Change of state of listening room members
- Intercepted call interruption: wx.onVoIPChatInterrupted
- Listen to the video status change of the member in the live voice call: wx.onVoIPVideoMembersChanged
- Members: wx.subscribeVoIPVideoMembers
# Signature Algorithm
To generate a signature, you need to enter four parameters:
| Parameter Name | Introductions |
|---|---|
| appId | Weixin Mini Program of appId |
| groupId | The unique identifier of the game room, guaranteed unique by the game itself |
| nonceStr | Random character string, less than 128 |
| timeStamp | Generates a UNIX timestamp (to the second) for this random character string |
The signature algorithm is:
// Hmac_sha256 requires developers to introduce their own
signature = hmac_sha256([appId, groupId, nonceStr, timeStamp].sort().join(''), sessionKey)
Specifically, this algorithm is divided into several steps:
- Yes
appId``groupId``nonceStr``timeStampThe four values are represented as character strings, sorted lexicographically; - Splicing the four character strings in sequence;
- Using
session_keyaskey,hmac_sha256 ``````````] [[TA-3-START]]]
Examples:
appId = 'wx20afc706a711eefc'
groupId = '1559129713_672975982'
nonceStr = '8AP6DT9ybtniUJfb'
timeStamp = '1559129714'
session_key = 'gDyVgzwa0mFz9uUP7M6GQQ=='
str = [appId, groupId, nonceStr, timeStamp].sort().join('') = '1559129713_67297598215591297148AP6DT9ybtniUJfbwx20afc706a711eefc'
signature = hmac_sha256('1559129713_67297598215591297148AP6DT9ybtniUJfbwx20afc706a711eefc', sessionKey) = 'b002b824688dd8593a6079e11d8c5e8734fbcb39a6d5906eb347bfbcad79c617'
# Use cloud development to complete signatures
In cloud development, thesession_keyis not available,But a separate function cloud.getVoIPSign is provided to calculate signatures.
const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
const signature = cloud.getVoIPSign({
groupId: 'xxx',
timestamp: 123,
nonce: 'yyy'
})
return signature
}
# Capacity limit
Up to 10 people can be joined in each room at the same time.
# Frequency Limit
For each Weixin Mini Program, a maximum of 100000 rooms are allowed to be created per day.When everyone exits the room, the room is destroyed. At this point, if you pass in a previously used groupId to rejoin the room, it will be counted as a new room.