Functional APIs

API List

MethodFeature
[new ClientSdk](#Create Client objects)Create a Client object
initInitialize
onAdd event bindings
joinRoomJoin a channel
leaveRoomLeave a channel
publishMediaPublish audio/video streams
unpublishMediaCancel audio/video stream publishing
subscribeMediaSubscribe to audio/video streams
unsubscribeMediaUnsubscribe to audio/video streams
enableLocalMediaResume local audio/video streams
disableLocalMediaDisable local audio/video streams
enableRemoteMediaEnable remote audio/video stream reception
disableRemoteMediaDisable remote audio/video stream reception

Details

Create a Client Object

- const SDK = require("../../lib/thunderblot_wechat_sdk.js");
- client = new SDK.ClientSdk();

init

init(appid: number): Err | null

This API initializes the SDK.

Parameters

ParameterDescription
appidService application ID

on

on(event: string, listener: any)

To add event bindings, refer to callback event for details

Parameters

ParameterDescription
eventEvent name
listenerCallback function

joinRoom

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.

Parameters

ParameterDescription
roomParamRoom information
RoomParam
interface RoomParam {
    uid: number;
    roomId: string;
    token?: string;    
}
ParameterDescription
uidnumber type, a 32-digit integer
roomIdRoom ID (unique) [only supports a combination of the characters [A,Z],[a,z],[0,9],-,_, not to exceed 64 bytes in length]
tokenSee [Authentication Access Manual] for details

leaveRoom

- leaveRoom(): void

Leave the channel, i.e. hanging up or exiting the conversation.

publishMedia

- 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):

ParameterDescription
audioAudio stream publishing, true: enable; false: disable
videoVideo stream publishing, true: enable; false: disable

unpublishMedia

Call to cancel pushing audio/video streams into the channel. You can call it at any point during publishing.

- unpublishMedia():void

subscribeMedia

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:

ParameterDescription
uidRemote user ID
targetSelect the subscribed media stream profile

Target (Select profile for the subscribed media stream):

ParameterDescription
audioSubscribe to remote user's audio stream
videoSubscribe to remote user's video stream

unsubscribeMedia

Call to cancel the subscription to a remote video stream.

-unsubscribeMedia(uid:number):void

Unsubscribe to remote media stream parameters:

ParameterDescription
uidRemote user ID

enableLocalMedia

Call to resume local audio/video stream publishing.

-enableLocalMedia(parm:param):void

Param (resume local audio/video stream publishing):

ParameterDescription
audioLocal user's audio stream output (i.e. voice)
videoLocal user's video stream output (i.e. video picture)

disableLocalMedia

Call to disable local audio/video stream publishing.

- disableLocalMedia(parm:param):void

param (disable local audio/video stream publishing):

ParameterDescription
audioLocal user's audio stream output (i.e. voice)
videoLocal user's video stream output (i.e. video picture)

enableRemoteMedia

Call to resume remote audio/video stream reception.

-enableRemoteMedia(uid:number,parm:param):void

param (resume remote audio/video stream reception)

ParameterDescription
audioRemote user's audio stream (i.e. voice)
videoRemote user's video stream (i.e. video picture)

disableRemoteMedia

Call to disable remote audio/video stream reception.

-disableRemoteMedia(uid:number,parm:param):void

param (disable remote audio/video stream reception)

ParameterDescription
audioRemote user's audio stream (i.e. voice)
videoRemote user's video stream (i.e. video picture)

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top
<