Table of Contents
Call sequence
You call somebody by calling wrtc.call(). The typical event sequence is then:
wrtc.call()
The call sequence starts by calling wrtc.call() with the address to call as an argument, eg wrtc.call("john.doe@company.com").
You can add additional arguments to the call, see wrtc.call() documentation.
wrtc.onNewCallObject()
wrtc_kit now creates a new call object, and calls wrtc.onNewCallObject() with the object as argument. wrtc.onNewCallObject() can then perform further initialization of the call object and GUI elements that will be displayed during the call.
wrtc.onLocalMedia()
If wrtc_kit had no previous access to local media (camera/microphone) it will request it now. The results, if access was granted or denied by user is reported by event function wrtc.onLocalMedia().
If wrtc_kit already has local media access the event will not occur.
wrtc.onConnecting()
Event handler function wrtc.onConnecting() is called to indicate wrtc_kit has started making the call. You can use this event to show user the call has begun, "dialing".
wrtc_kit now contacts the client you want to call. IXNX will if necessary convert the call to a SIP call or even route it through a PSTN gateway to old fashioned telephone network.
wrtc.onRinging()
When a connection has been established the phone at the other end will start ringing. wrtc_kit then calls event function wrtc.onRinging(). The event indicates that the other phone has been found and actually started to ring. You can use this event to indicate to user remote phone is ringing (usually by playing a ringing sound).
wrtc.onEarlyMedia()
Some remote clients may start transmitting sound to you before the actual call has been set up and started. It is called "early media". Early media is usually used to transmit the remote ringing sound to you. To avoid having double ringing sounds, the local one you generated at wrtc.onRinging() and the remote one you receive through early media you should use the wrtc.onEarlyMedia() function to turn off the local ringing sound.
wrtc.onTalking()
When other side has picked up the phone event function wrtc.onTalking() is called. You are now on the phone. In a video call you should now rearrange your display to show the person you are talking to.
Different outcomes
The call sequence can run into trouble connecting the call. The two most common reasons why a call cannot be made is you are trying to call someone unknown or the person you call denies your call. In both cases you event function wrtc.onGotHungUp() is called:
404 Not Found
If the address you try to call is not found you will instead of wrtc.onRinging() above get a wrtc.onGotHungUp() event function call with second argument:
{type:"esc", response:404, msg:"Not Found", partner:addr}
- addr - the address you tried to call
In your wrtc.onGotHungUp() you should play a "too-duu-dee" wrong number tone upon receiving response code 404.
486 Busy Here
If the person you are trying to call denies your call you will instead of wrtc.onTalking() above get a wrtc.onGotHungUp() event function call with second argument:
{type:"esc", response:486, msg:"Busy Here", partner:addr}
- addr - the address you tried to call
In your wrtc.onGotHungUp() you should play a "titititi" busy tone upon receiving response code 486.