proxystore.p2p.server
Signaling server implementation for WebRTC peer connections.
Client
dataclass
¶
SignalingServer ¶
Signaling Server implementation.
The Signaling Server acts as a public third-party that helps two peers (endpoints) establish a peer-to-peer connection during the WebRTC peer connection initiation process. The signaling server's responsibility is just to forward session descriptions between two peers, so the server can be relatively lightweight and typically only needs to transfer two messages to establish a peer connection, after which the peers no longer need the signaling server.
To learn more about the WebRTC peer connection process, check out https://webrtc.org/getting-started/peer-connections.
The signaling server is built on websockets and designed to be
served using websockets.serve()
.
Example
Source code in proxystore/p2p/server.py
send
async
¶
Send message on the socket.
Parameters:
-
websocket
(
WebSocketServerProtocol
) –Websocket to send message on.
-
message
(
messages.Message
) –Message to json encode and send.
Source code in proxystore/p2p/server.py
register
async
¶
Register peer with Signaling Server.
Parameters:
-
websocket
(
WebSocketServerProtocol
) –Websocket connection with client wanting to register.
-
request
(
messages.ServerRegistration
) –Registration request message.
Source code in proxystore/p2p/server.py
unregister
async
¶
Unregister the endpoint.
Parameters:
-
websocket
(
WebSocketServerProtocol
) –Websocket connection that was closed.
-
expected
(
bool
) –If the connection was closed intentionally or due to an error.
Source code in proxystore/p2p/server.py
connect
async
¶
Pass peer connection messages between clients.
Parameters:
-
websocket
(
WebSocketServerProtocol
) –Websocket connection with client that sent the peer connection message.
-
message
(
messages.PeerConnection
) –Message to forward to peer client.
Source code in proxystore/p2p/server.py
handler
async
¶
Websocket server message handler.
Parameters:
-
websocket
(
WebSocketServerProtocol
) –Websocket message was received on.
-
uri
(
str
) –URI message was sent to.
Source code in proxystore/p2p/server.py
serve
async
¶
Run the signaling server.
Initializes a SignalingServer
and starts a websocket server listening on host:port
for new connections
and incoming messages.
Parameters:
-
host
(
str
) –Host to listen on.
-
port
(
int
) –Port to listen on.
-
certfile
(
str | None
) –Optional certificate file (PEM format) to enable TLS while serving.
-
keyfile
(
str | None
) –Optional private key file. If not specified, the key will be taken from the certfile.
Source code in proxystore/p2p/server.py
main ¶
CLI for starting the signaling server.
Source code in proxystore/p2p/server.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|