Suggestions

close search

StringeeRoom

This class provides methods to make or join a room chat as a video conference.

Props

eventHandlers: Object

Event handlers passed into the native StringeeRoom instance. For example:


            roomEventHandlers = {
              onRoomConnect: this._onRoomConnect,
              onRoomDisConnect: this._onRoomDisConnect,
              onRoomError: this._onRoomError,
              onStreamAdd: this._onStreamAdd,
              onStreamRemove: this._onStreamRemove
            };
          

Events

onRoomConnect : Function(roomId: int, streams: array)

Invoked when the client makes/joins a room successfully. You will receive other clients'streams and can subscribe them:
- roomId: The room's id generated by Stringee server.
- streams: The streams list of the room.

onRoomDisConnect : Function(roomId: int)

Invoked when the client disconnects from a room:
- roomId: The room's id generated by Stringee server.

onRoomError : Function(roomId: int,code: int, message: string)

Invoked when the client fails to make/join a room:
- roomId: The room id.
- code: The error code.
- message: The error message.

onStreamAdd : Function(roomId: string, stream: object)

Invoked when the other client's stream is published. You can subscribe the stream:
- roomId: The room's id generated by Stringee server.
- stream: The stream (userId, streamId) which is published to the room.

onStreamRemove : Function(roomId: string, stream: object)

Invoked when another client leaves the room, the client's stream will be removed. You should change your UI:
- roomId: The room's id generated by Stringee server.
- stream: The stream(userId, streamId) which is unpublished from the room.

Functions

makeRoom(callback: (status, code, message, roomId))

Makes a room with a callback:
- status = true, code = 0, message = "Make room successfully"
- status = false, code = 1, message = "The number of rooms exceeds the limit."
- status = false, code = -1, message = "The client is not connected to Stringee Server"
- status = false, code = -2, message = "Generic error" - roomId: The room id when created.

joinRoom(roomId: string, callback: (status, code, message, roomId))

Joins a room with a callback:
- status = true, code = 0, message = "Join room successfully"
- status = false, code = 1, message = "Room is not exist."
- status = false, code = -1, message = "The client is not connected to Stringee Server"
- status = false, code = -2, message = "Generic error"
- status = false, code = -3, message = "RoomId is invalid."

publishLocalStream(roomId: int, config: string, callback: (status, code, message, streamId))

Publishes LocalStream to the room:
- roomId: The room's id generated by Stringee server.
- config: The local stream config in json format. For example:


                const config = {
                  videoResolution: "from"
                };
              
- status: the result:
    true: success
    false: failure
- code:
    0: success
    -1: The room id is invalid.
    -2: The room is not found.
- message: The result's description.
- streamId: The stream id returned from Stringee Server when the stream is published successfully.

unPublishLocalStream(roomId: int, streamId: string, callback: (status, code, message))

Unpublishes LocalStream:
- roomId: The room's id generated by Stringee server.
- streamId: The stream id which generated by Stringee Server when the stream is published successfully.
- status: The result:
    true: success
    false: failure
- code:
    0: success
    -1: The room id is invalid.
    -2: The room is not found.
    -3: The stream id is invalid.
    -4: The stream is not found.
- message: The result's description.

subscribe(roomId: int, streamId: string, callback: (status, code, message))

Subscibes a stream:
- roomId: The room's id generated by Stringee server.
- streamId: The stream's id generated by Stringee server.
- status: The result:
    true: success
    false: failure
- code:
    0: success
    -1: The room id is invalid.
    -2: The room is not found.
    -3: The stream id is invalid.
    -4: The stream is not found.
- message: The result's description.

unSubscribe(roomId: int, streamId: string, callback: (status, code, message))

Unsubscibes a stream:
- roomId: The room's id generated by Stringee server.
- streamId: The stream's id generated by Stringee server.
- status: The result:
    true: success
    false: failure
- code:
    0: success
    -1: The room id is invalid.
    -2: The room is not found.
    -3: The stream id is invalid.
    -4: The stream is not found.
- message: The result's description.

destroy(roomId: int, callback: (status, code, message))

Destroys a room and releases resources:
- roomId: The room's id generated by Stringee server.
- status: The result:
    true: success
    false: failure
- code:
    0: success
    -1: StringeeClient is not initialized or connected.
    -2: The room id is invalid.
    -3: The room is not found.
- message: The result's description.

switchCamera()

Switches the device's camera.

mute(isMute: boolean)

Toggles audio on or off:
- isMute = true: toggles audio off.
- isMute = false: toggles audio on.

turnOnCamera(isOn: boolean)

Toggles audio on or off:
- isOn = true: enables video.
- isOn = false: disables video.

setSpeakerphoneOn(isOn: boolean)

Toggles audio on or off:
- isOn = true: loud speaker.
- isOn = false: headset speaker.

getStats(roomId: int, streamId: string, useVideoTrack: boolean, callback: (status, message, stats))

Gets the call's statistics:
- roomId: The room's id generated by Stringee server.
- streamId: The stream's id generated by Stringee server.
- useVideoTrack = true: Get the video track's statistics, useVideoTrack = false: Get the audio track's statistics.
- status: The result:
    + true: success
    + false: failure
- message: The result's description. - stats: The call's statistics in JSON string.