Suggestions

close search

StringeeCall2

This component provides methods to make/receive a Stringee call2. It contains all data of a call.

Props

clientId: String

Id of StringeeClient

eventHandlers: Object

Event handlers passed into the native StringeeCall2 instance. Example:


            callEventHandlers = {
              onChangeSignalingState: this._callDidChangeSignalingState,
              onChangeMediaState: this._callDidChangeMediaState,
              onReceiveLocalStream: this._callDidReceiveLocalStream,
              onReceiveRemoteStream: this._callDidReceiveRemoteStream,
              onReceiveCallInfo: this._didReceiveCallInfo,
              onHandleOnAnotherDevice: this._didHandleOnAnotherDevice
              onAudioDeviceChange: this._didAudioDeviceChange,
            };
          

Events

onChangeSignalingState : Function(callId: string, code: int, reason: string, sipCode: int, sipReason: string)

Invoked when the call's state changes between: calling, ringing, answered, busy, ended:
- callId: The call's id generated by Stringee server.
- code: The signaling state of the call:
    + code = 0, Used to specify the call invite is sent to Stringee Server.
    + code = 1, Used to specify the callee is ringing.
    + code = 2, Used to specify the callee answers the call.
    + code = 3, Used to specify the callee rejects the call.
    + code = 4, Used to specify the call is terminated.
- reason: The description of the state.
- sipCode: The sip code returned when the call is an app-to-phone call.
- sipReason: The description of sip code.

onChangeMediaState : Function(callId: string, code: int, description: string)

Invoked when the call media state changes between: connected, disconnected:
- callId: The call's id generated by Stringee server.
- code: The media state of the call:
    + code = 0, Used to specify the call media is connected.     + code = 1, Used to specify the call media is disconnected. - description: The description of the state.

onReceiveLocalStream : Function(callId: string)

Invoked when the local stream is initialized and available to be rendered to a view:
- callId: The call's id generated by Stringee server.

onReceiveRemoteStream : Function(callId: string)

Invoked when the client receives a remote stream and can render it to a view:
- callId: The call's id generated by Stringee server.

onReceiveDtmfDigit : Function(callId: string, dtmf: string)

Invoked when the client receives a DTMF:
- callId: The call's id generated by Stringee server.
- dtmf: DTMF code ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "*", #)

onReceiveCallInfo : Function(callId: string, data: string)

Invoked when you receive info from another client:
- callId: The call's id generated by Stringee server.
- data: Data received in JSON string format.

onHandleOnAnotherDevice : Function(callId: string, code: int, description: string)

Invoked when the call is implemented on another device:
- callId: The call's id generated by Stringee server.
- code: The signaling state of the call:
    + code = 1, Used to specify the callee is ringing.
    + code = 2, Used to specify the callee answers the call.
    + code = 3, Used to specify the callee rejects the call.
    + code = 4, Used to specify the call is terminated.

onAudioDeviceChange : Function(selectedAudioDevice: string, availableAudioDevices: string)

This event only invoked in android.
Invoked when device change audio device:
- availableAudioDevices: List avaiable audio devices on your android device.
- selectedAudioDevice: Audio device was selected:
    + SPEAKER_PHONE : Speaker phone.
    + WIRED_HEADSET : Wired headset.
    + EARPIECE : Earpiece.
    + BLUETOOTH : Bluetooth headphone.
    + NONE : None device selected.

Functions

makeCall(parameters: string, callback: (status, code, message, customDataFromYourServer))

Make a call with parameters and then returns a callback:
- parameters: parameters of the call. Example:


                  const myObj = {
                    from: "from",
                    to: "to",
                    isVideoCall: false,
                    videoResolution: "NORMAL",
                    customData: ""
                  };
                
    + from: The caller's phone number or id.
    + to: The callee's phone number or id.
    + isVideoCall: Whether the call is a video call, isVideoCall = YES -> a video call, isVideoCall = NO -> a voice call
    + videoResolution: The local video's resolution ("NORMAL" or "HD")
    + customData: This is a customizable text of the call. This text will be sent to Stringee server. Then Stringee server sends it to Your Server via the project's answer_url.
- callback returns the result:
    + status = true, code = 0, message = "Make call successfully"
    + status = false, code = 1, message = "Make call failed. Answer url is empty"
    + status = false, code = 2, message = "Make call failed. Answer url scco incorrect format"
    + status = false, code = 3, message = "Make call failed. To type is not internal or external"
    + status = false, code = 4, message = "Make call failed. From number not found"
    + status = false, code = 5, message = "Make call failed. From number not belong your account"
    + status = false, code = 6, message = "Make call failed. SIP Trunk not found"
    + status = false, code = 7, message = "Make call failed. SIP Trunk not belong your account"
    + status = false, code = 8, message = "Make call failed. Not enough money"
    + status = false, code = -1, message = "Make call failed. The client is not connected to Stringee Server"
    + status = false, code = -2, message = "Make call failed. Generic error"
    + status = false, code = -4, message = "Make call failed. The parameters format is invalid."
- customDataFromYourServer: The custom data from your server when a client makes a call or receives an incoming call.

initAnswer(callId: string, callback: (status, code, message))

Initializes an answer. Must be implemented before you can answer a call:
- callId: The call's id.
- callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -1, message = "StringeeClient is not initialzied or connected."
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

answer(callId: string, callback: (status, code, message))

Answer a call:
- callId: The call's id.
- callback returns the result:
    + status = true, code = 0, message = "Answer call successfully"
    + status = false, code = 1, message = "Answer call failed. The call is not exist"
    + status = false, code = 2, message = "Answer call failed. The call was controlled from other device"
    + status = false, code = 3, message = "Answer call failed. Call data is not exist"
    + status = false, code = -1, message = "Answer call failed. The client is not connected to Stringee Server."
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

hangup(callId: string, callback: (status, code, message))

Hangup a call:
- callId: The call's id.
- callback returns the result:
    + status = true, code = 0, message = "Hangup call successfully"
    + status = false, code = 1, message = "Hangup call failed. The call is not exist."
    + status = false, code = 2, message = "Hangup call failed. The call answered on another device."
    + status = false, code = -1, message = "Hangup call failed. The client is not connected to Stringee Server."
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

reject(callId: string, callback: (status, code, message))

Reject a call:
- callId: The call's id.
- callback returns the result:
    + status = true, code = 0, message = "Reject call successfully."
    + status = false, code = 1, message = "Reject call failed. The call is not exist."
    + status = false, code = 2, message = "Reject call failed. The call answered on another device."
    + status = false, code = -1, message = "Reject call failed. The client is not connected to Stringee Server."
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

sendCallInfo(callId: string, callInfo: string, callback: (status, code, message))

Send info to another client:
- callId: The call's id.
- callInfo: data you want to send, in JSON string.
- callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -1, message = "StringeeClient is not initialzied or connected."
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."
    + status = false, code = -4, message = "The callInfo format is invalid."

getCallStats(callId: string, callback: (status, code, message, stats))

Gets the call's statistics:
- callId: The call's id.
- callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -1, message = "StringeeClient is not initialzied or connected."
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."
    + stats: The call's statistics in JSON string.

switchCamera(callId: string, callback: (status, code, message))

Switches the device's camera:
- callId: The call's id
- callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

enableVideo(callId: string, enabled: boolean, callback: (status, code, message))

Enables or disables local video:
- callId: The call's id
- enabled = true, enables local video. - enabled = false, disables local video. - callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

mute(callId: string, mute: boolean, callback: (status, code, message))

Toggles audio on or off:
- callId: The call's id
- mute = true, toggles audio off. - mute = false, toggles audio on. - callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

setSpeakerphoneOn(callId: string, on: boolean, callback: (status, code, message))

Set the audio output mode:
- callId: The call's id
- on = true, loud speaker. - on = false, headset speaker. - callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."

resumeVideo(callId: string, callback: (status, code, message))

Resume local stream:
- callId: The call's id
- callback returns the result:
    + status = true, code = 0, message = "Success"
    + status = false, code = -2, message = "The callId is invalid."
    + status = false, code = -3, message = "The call is not found."