Crate wasm_peers

Crate wasm_peers 

Source
Expand description

This crate provides an easy-to-use wrapper around WebRTC and DataChannels for a peer to peer connections.

§Overview

As creator of agar.io famously stated WebRTC is hard. This library aims to help, by abstracting away all the setup, and providing a simple way to send and receive messages over the data channel.

It’s as easy as providing address to a signaling server instance from accompanying crate and specifying two callbacks. One for when a connection opens, and one for when a message is received. After that you can send messages back and forth without worrying about the implementation details.

Library contains three network , one-to-one, which creates an equal connection between two peers, one-to-many, which specifies a host and arbitrary number of clients and [many-to-many] that creates connection for each pair of peers and allows sending messages to any of them.

Modules§

many_to_many
Library module for implementation of the many-to-many topology of peer communication.
one_to_many
Library module for the one-to-many topology in client-server architecture. There can be exactly one instance of MiniServer and arbitrary number of MiniClient’s connected to the same session.
one_to_one
Library module for one-to-one network topology in simple tunnel connection.

Structs§

SessionId
Unique identifier of signaling session that each user provides when communicating with the signaling server.
UserId
Unique identifier of each peer connected to signaling server useful when communicating in one-to-many and many-to-many topologies.

Enums§

ConnectionType
Specifies what kind of peer connection to create

Functions§

get_random_session_id
Returns a new SessionId instance that can be used to identify a session by signaling server.