Lines

The line layer of RTCgate takes care of managing multiple "phone lines", multiple calls made by the same client.

Each line can take care of one call. If you want to have multiple calls to several different people at once you will need to have multiple "lines" - one for each call.

Each RTCgate command must have it's line specified, to separate them when running multiple calls. Receiving a "ringing" message when you have only one call is straightforward - but what if you are in a group call with three different people? Which call was ringing? The line number will tell: {"line":"1","type":"ringing"} means call number two is the one ringing (lines start from 0).

First line

Line 0 is created automatically by wrtc_kit when it starts. Wrtc_kit opens a websocket connection, creates line 0 and logs in:

C->S: {"line":"0","wcw_seq":"1","type":"Iam","name": ... }
S->C: {"wcw_ack":"1"}
S->C: {"line":"0","wcw_seq":"1","type":"welcome"}
C->S: {"wcw_ack":"1"}

As you can see only data packets that contain RTCgate commands have line arguments. Data packets containing only wcw layer stuff do not have line arguments because the wcw layer is the same for the whole websocket.

Second line

Once you receive an incoming call on line 0 that line becomes busy. It cannot receive any more calls. One line = one call.

In order to be able to make or receive more calls while you are busy on line 0 you need to create a line 1:

S->C: {"line":"0","wcw_seq":"9","type":"offer","sdp": ... }
C->S: {"wcw_ack":"9"}
C->S: {"line":"1","wcw_seq":"591","type":"Iam","name": ... }
S->C: {"wcw_ack":"591"}
C->S: {"line":"0","wcw_seq":"592","type":"ringing"}
S->C: {"wcw_ack":"592"}
S->C: {"line":"1","wcw_seq":"10","type":"welcome"}
C->S: {"wcw_ack":"10"}

An incoming offer on line 0 makes wrtc_kit automatically start a line 1 and send an Iam message on it. At the same time it sends back a ringing message on line 0. The line numbers help keep the messages apart, which messages are for the call being started and which messages are for the new line that will be ready to receive new calls in the future.

Notice how the wcw_seq numbers are increasing regardless of what line the command is using, and they are different for client and server side.

Now that the user is engaged in a call on line 0 any new incoming calls will use line 1, IXNX server will send its offer message on line 1. If call is started by this client it will also use line 1 to send its offer message.

During a call line 0 takes care of the call and line 1 is standing by to be able to receive any new incoming calls (or make them). If line 1 also receives a call a line 2 is automatically started, etc. (Until the maximum number of calls set by wrtc.maxNrCalls is reached.)

Ending a line

When you end the call the extra line ready to receive calls is no longer needed. In below example line 0 was having a call and line 1 was open to receive any incoming second calls. When user hangs up the call line 0 sends an esc message to indicate call has been ended (and it is ready to receive new calls) and line 1 sends a bye message indicating that line is no longer valid:

call0: Hanging up
call0: stop call
C->S: {"line":"0","wcw_seq":"71","type":"esc"}
C->S: {"line":"1","wcw_seq":"72","type":"bye"}
S->C: {"wcw_ack":"71"}
S->C: {"wcw_ack":"72"}

From this moment on IXNX server will no longer send any messages on line 1, and do not accept any more messages on line 1 either. Any new calls will be made on line 0 again.

socket 0 line 0

As soon as wrtc_kit is started it opens websocket 0 and creates line 0 on it. As user makes calls line 1, 2, 3 etc might be created and ended dynamically but line 0 is never terminated. There is always a line 0 open - even if client is in idle mode without any calls in progress. Socket 0 line 0 is only terminated when client is terminated.

multiple lines

During complex call scenarios (eg group call) there might be several calls in progress simultaneously, each using its own line - plus one idle line ready to make or receive new calls. For example 3 simultaneous calls might have:

  • line 0 handling the first call
  • line 1 handling the second call
  • line 2 handling the third call
  • line 3 standing by to make or receive further calls

Now if the second call is ended line 1 will go back to stand by, ready to receive calls again. Line 3 will terminate (send bye) because it is not needed any more. All other lines are unaffected:

  • line 0 handling the first call
  • line 1 standing by to make or receive further calls
  • line 2 handling the third call

If a fourth call is started it will use line 1, and a line 3 is created again to stand by for further calls:

  • line 0 handling the first call
  • line 1 handling the fourth call
  • line 2 handling the third call
  • line 3 standing by to make or receive further calls

wrtc_kit should always strive to use the line with lowest number available to stand by for new calls.

Line states

As soon as a line has been created on client it sends Iam message to server. Server answers with welcome. Server might create a new SIP endpoint that might need authentication thus server might send unauthorised message to client.

After that line is in stand by state, ready to make or receive calls.

A call is started by either sending or receiving an offer message.

After that line moves to call state, taking care of a call. While in call state that line cannot make or receive any further calls. One line can only handle one call. To be able to stand by for receiving other calls client must start a new line.

A call is ended by either sending or receiving an esc message.

After that line moves back to stand by state, ready to make or receive new calls again.

The line is terminated by either sending or receiving a bye message.

After that line is terminated and cannot be used again. Server might terminate any SIP endpoint it had running.

ixnx/wrtc/rtcgate/lines.txt · Last modified: by tibor
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0