@@ -45,8 +45,8 @@ var pc = new RTCPeerConnection({
45
45
});
46
46
```
47
47
48
- The [ example directory ] ( https://github.com/lambdaclass/webrtc-server/tree/master/example )
49
- contains a full Cowboy application using ` webrtc_server ` and a simple
48
+ The [ examples/simple ] ( https://github.com/lambdaclass/webrtc-server/tree/master/examples/simple )
49
+ directory contains a full Cowboy application using ` webrtc_server ` and a
50
50
browser client that establishes a WebRTC connection using the
51
51
Signaling and ICE servers.
52
52
@@ -106,6 +106,13 @@ Both callbacks receive the same arguments:
106
106
` infinity ` to disable idle timeouts.
107
107
108
108
## Signaling API reference
109
+
110
+ The signaling API is used by web socket clients to exchange the
111
+ necessary information to establish a WebRTC peer connection. See
112
+ the
113
+ [ examples] ( https://github.com/lambdaclass/webrtc-server/tree/master/examples )
114
+ for context on how this API is used.
115
+
109
116
### Authentication
110
117
After connection, an authentication JSON message should be sent:
111
118
@@ -119,23 +126,71 @@ After connection, an authentication JSON message should be sent:
119
126
}
120
127
```
121
128
122
- The server will reply with this payload:
129
+ The server will assign a ` peer_id ` to the client and reply:
130
+
131
+ ``` json
132
+ {
133
+ "event" : " authenticated" ,
134
+ "data" : {
135
+ "peer_id" : " bxCBrwyL3Ar7Nw=="
136
+ }
137
+ }
138
+ ```
139
+
140
+ The rest of the peers in the room will receive a ` joined ` event:
123
141
124
142
``` json
125
143
{
126
144
"event" : " joined" ,
127
145
"data" : {
128
146
"username" : " john" ,
129
- "peer_id" : " bxCBrwyL3Ar7Nw==" ,
130
- "peers" : [" 7nN1q/qarRnejQ==" ]
147
+ "peer_id" : " bxCBrwyL3Ar7Nw=="
148
+ }
149
+ }
150
+ ```
151
+
152
+ Similarly, when a client leaves the room, the rest of the peers will
153
+ receive a ` left ` event:
154
+
155
+ ``` json
156
+ {
157
+ "event" : " left" ,
158
+ "data" : {
159
+ "username" : " john" ,
160
+ "peer_id" : " bxCBrwyL3Ar7Nw=="
131
161
}
132
162
}
133
163
```
134
164
135
- ### Room messages
165
+ ### Signaling messages
166
+
167
+ After authentication, all messages sent by the client should be
168
+ signaling messages addressed to a specific peer in the room, including a ` to `
169
+ field. The event and data are opaque to the server (they can be
170
+ ice candidates, session descriptions, or whatever clients need to
171
+ exchange). For example:
136
172
137
- After authentication, any (non ping) message sent will be forwarded to
138
- the rest of the clients connected to the room.
173
+ ``` json
174
+ {
175
+ "event" : " candidate" ,
176
+ "to" : " 458/53WAkeu+tQ==" ,
177
+ "data" : {
178
+ ...
179
+ }
180
+ }
181
+ ```
182
+
183
+ The addressed peer will receive this payload:
184
+
185
+ ``` json
186
+ {
187
+ "event" : " candidate" ,
188
+ "from" : " bxCBrwyL3Ar7Nw==" ,
189
+ "data" : {
190
+ ...
191
+ }
192
+ }
193
+ ```
139
194
140
195
### Ping
141
196
To send a keepalive message to prevent idle connections to be droped
0 commit comments