Method | Feature |
---|---|
[new ClientSdk](#Create Client objects) | Create a Client object |
init | Initialize |
on | Add event bindings |
joinRoom | Join a channel |
leaveRoom | Leave a channel |
publishMedia | Publish audio/video streams |
unpublishMedia | Cancel audio/video stream publishing |
subscribeMedia | Subscribe to audio/video streams |
unsubscribeMedia | Unsubscribe to audio/video streams |
enableLocalMedia | Resume local audio/video streams |
disableLocalMedia | Disable local audio/video streams |
enableRemoteMedia | Enable remote audio/video stream reception |
disableRemoteMedia | Disable remote audio/video stream reception |
- const SDK = require("../../lib/thunderblot_wechat_sdk.js");
- client = new SDK.ClientSdk();
init(appid: number): Err | null
This API initializes the SDK.
Parameter | Description |
---|---|
appid | Service application ID |
on(event: string, listener: any)
To add event bindings, refer to callback event for details
Parameter | Description |
---|---|
event | Event name |
listener | Callback function |
joinRoom(roomParam: RoomParam)
This API allows users to join the communication channel.
Users in the channel can communicate with one another or engage in group chat. Applications using different application IDs cannot intercommunicate. If you are already in the midst of communication, you must exit by calling leaveRoom() before you can join the next channel.
Parameter | Description |
---|---|
roomParam | Room information |
interface RoomParam {
uid: number;
roomId: string;
token?: string;
}
Parameter | Description |
---|---|
uid | number type, a 32-digit integer |
roomId | Room ID (unique) [only supports a combination of the characters [A,Z],[a,z],[0,9],-,_, not to exceed 64 bytes in length] |
token | See [Authentication Access Manual] for details |
- leaveRoom(): void
Leave the channel, i.e. hanging up or exiting the conversation.
- publishMedia(publishParam:publishParam):void
Call this API to push audio/video streams into the channel for live streaming. You must join the channel before calling. Returns the published audio/video stream's URL to users through the update_publish_url callback event. publishParam (the channel stream information parameter):
Parameter | Description |
---|---|
audio | Audio stream publishing, true: enable; false: disable |
video | Video stream publishing, true: enable; false: disable |
Call to cancel pushing audio/video streams into the channel. You can call it at any point during publishing.
- unpublishMedia():void
Send a remote media stream notification to users who join the channel. Then receiving the message triggers the "remote_stream_add" callback event. Subscription then requires this API.
-subscribeMedia(uid:number,target:object):void
Subscribed remote media stream parameters:
Parameter | Description |
---|---|
uid | Remote user ID |
target | Select the subscribed media stream profile |
Target (Select profile for the subscribed media stream):
Parameter | Description |
---|---|
audio | Subscribe to remote user's audio stream |
video | Subscribe to remote user's video stream |
Call to cancel the subscription to a remote video stream.
-unsubscribeMedia(uid:number):void
Unsubscribe to remote media stream parameters:
Parameter | Description |
---|---|
uid | Remote user ID |
Call to resume local audio/video stream publishing.
-enableLocalMedia(parm:param):void
Param (resume local audio/video stream publishing):
Parameter | Description |
---|---|
audio | Local user's audio stream output (i.e. voice) |
video | Local user's video stream output (i.e. video picture) |
Call to disable local audio/video stream publishing.
- disableLocalMedia(parm:param):void
param (disable local audio/video stream publishing):
Parameter | Description |
---|---|
audio | Local user's audio stream output (i.e. voice) |
video | Local user's video stream output (i.e. video picture) |
Call to resume remote audio/video stream reception.
-enableRemoteMedia(uid:number,parm:param):void
param (resume remote audio/video stream reception)
Parameter | Description |
---|---|
audio | Remote user's audio stream (i.e. voice) |
video | Remote user's video stream (i.e. video picture) |
Call to disable remote audio/video stream reception.
-disableRemoteMedia(uid:number,parm:param):void
param (disable remote audio/video stream reception)
Parameter | Description |
---|---|
audio | Remote user's audio stream (i.e. voice) |
video | Remote user's video stream (i.e. video picture) |