v0.0.X

Signal exchange with examples

S – Server
C – Client
CM – Client registered in server as potencial member of conversation


 

Connect to server via websocket:

C				S
|				|
|	-> 1 ->		|
|				|
(2)				|
|				|

(1) open websocket connection
(2) C became CM


 

Send command to create conversation:

CM				S
|				|
|	-> 1 ->		|
|				|
|	<- 2 <-		|
|				|

(1) send signal “create” with optional conversation name
(2) receive “created” with unique conversation Id – this conversation id can be shared to allow other user to join to conversation

Sample payload is presented below:

(1)	{
		"from":"",
		"to":"",
		"signal":"create",
		"content":"",
		"custom":{}
	}
(2) 	{
		"from":"",
		"to":"CM",
		"signal":"created",
		"content":"<conversation name>",
		"custom":{}
	}

 

Send command to join to conversation:

CM				S
|				|
| 	-> 1 ->	 	|
|				|
|	<- 2 <-		|
|				|

(1) send signal “join” with conversation name
(2) receive “joined” this signal inform client that everything want right.

Sample payload is presented below:

(1) 	{
		"from":"",
		"to":"",
		"signal":"join",
		"content":"<conversation name>",
		"custom":{}
	}
(2)	 {
		"from":"",
		"to":"CM",
		"signal":"joined",
		"content":"<conversation name>",
		"custom":{}
	}

Signal join triggers also additional actions connected with procces of setting up WebRTC connection.


 

Whole process of create and join clients are shown below:

CM1			S			CM2
|			| 			|
|	-> 1 -> 	| 			|
| 			| 			|
|	<- 2 <-	| 			|
| 			| 			|
| ~	   3	 ~ 	~ 	~ 	~ ~>|
| 			| 			|
| 			|	<- 4 <-	|
| 			| 			|
| 			| 	-> 5 ->	|
|	<- 5'<-	| 			|
|	<- 6 <-	| 			|
| 			| 			|

(1) CM1 send signal “create” with optional conversation name
(2) CM1 receive signal “created” with conversation name
(3) CM1 share conversation name to CM2
(4) CM2 send signal “join” with required conversation name (received from CM1)
(5) CM2 receive signal “joined” with conversation name
(5′) CM1 receive signal “joined” from CM2 (in this way CM1 can read CM1 unique id)
(6) CM1 receive signal “offerRequest” from CM2 this signal trigger WebRTC signal exchange protocol

Sample payload is presented below:

(1) 	{
		"from":"",
		"to":"",
		"signal":"create",
		"content":"",
		"custom":{}
	}
(2) 	{
		"from":"",
		"to":"CM1",
		"signal":"created",
		"content":"<conversation name>",
		"custom":{}
	}
(3) -------------
(4) 	{
		"from":"",
		"to":"",
		"signal":"join",
		"content":"<conversation name>",
		"custom":{}
	}
(5) 	{
		"from":"",
		"to":"CM2",
		"signal":"joined",
		"content":"<conversation name>",
		"custom":{}
	}
(5') 	{
		"from":"CM2",
		"to":"CM1",
		"signal":"joined",
		"content":"",
		"custom":{}
	}
(6) 	{
		"from":"CM2",
		"to":"CM1",
		"signal":"offerRequest",
		"content":"",
		"custom":{}
	}

Signal “offerRequest” begins SPDs exchange.


 

SPDs exchange protocol is shown below:

CM1			S			CM2
|			|			|
| 	<- 1 <-	|			|
x1			|			|
| 	-> 2 -> 	|			|
|			|			|
|			|	-> 3 ->	|
|			|			x3
|			|	<- 4 <-	|
|			|			|
|	<- 5 <-	|			|
|			|			|
|	-> 6 ->	|	-> 7 ->	|
|	<- 9 <-	|	<- 8 <-	|
|			|			|

(1) Server send signal “offerRequest” from CM2 to CM1
(x1) CM1 have to get local media and obtain SPD
(2) CM1 send signal “offerResponse” to Server in content CM1 send his SPD
(3) Server send signal “answerRequest” to CM2 in content Server provide CM1 SPD
(x3) CM2 have to get local media and obtain SPD (same action like in x1)
(4) CM2 send signal “answerResponse” to Servier in content CM2 send his SPD
(5) Server send signal “finalize” to CM1 in content Server provide CM2 SPD
(6) CM1 send signal “candidate” to in content sends SPD candidate
(7) Server propagate signal to CM2
(8) CM2 receive signal “candidate” and give response with his SPD candidate
(9) Server propagate signal to CM1
Now both clients can see each other.

Sample payload:

(1)	{
		 "from":"CM2",
		 "to":"CM1",
		 "signal":"offerRequest",
		 "content":"","custom":{}
	}
(2)	{
		 "from":"",
		 "to":"CM2",
		 "signal":"offerResponse",
		 "content":"CM1 SPD",
		 "custom":{}
	}
(3)	{
		 "from":"CM1",
		 "to":"CM2",
		 "signal":"answerRequest",
		 "content":"CM1 SPD",
		 "custom":{}
	}
(4)	{
		 "from":"",
		 "to":"CM1",
		 "signal":"answerResponse",
		 "content":"CM2 SPD",
		 "custom":{}
	}
(5)	{
		 "from":"CM2",
		 "to":"CM1",
		 "signal":"finalize",
		 "content":"CM2 SPD",
		 "custom":{}
	}
(6)	{
		 "from":"",
		 "to":"CM2",
		 "signal":"candidate",
		 "content":"CM1 CANDIDATE",
		 "custom":{}
	}
(7)	{
		 "from":"CM1",
		 "to":"CM2",
		 "signal":"candidate",
		 "content":"CM1 CANDIDATE",
		 "custom":{}
	}
(8)	{
		 "from":"",
		 "to":"CM1",
		 "signal":"candidate",
		 "content":"CM2 CANDIDATE",
		 "custom":{}
	}
(9)	{
		 "from":"CM2",
		 "to":"CM1",
		 "signal":"candidate",
		 "content":"CM2 CANDIDATE",
		 "custom":{}
	}

 

Leave a Reply