All Projects β†’ johanhelsing β†’ matchbox

johanhelsing / matchbox

Licence: Unknown and 2 other licenses found Licenses found Unknown LICENSE Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Painless peer-to-peer WebRTC networking for rust wasm

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to matchbox

Webrtc
Pure Go implementation of the WebRTC API
Stars: ✭ 8,399 (+2943.12%)
Mutual labels:  p2p, wasm
peermesh
πŸ’« Exchange files p2p and e2e encrypted over a fully meshed network in your browser using WebRTC.
Stars: ✭ 107 (-61.23%)
Mutual labels:  mesh-networks, p2p
Waykichain
Public Blockchain as a Decentralized Finance Infrastructure Service Platform
Stars: ✭ 1,117 (+304.71%)
Mutual labels:  p2p, wasm
safenetwork-gitportal
p2p git portal - a decentralised alternative to github
Stars: ✭ 12 (-95.65%)
Mutual labels:  p2p, wasm
P2p Internet Workshop
Building the Peer-to-Peer Internet workshop series
Stars: ✭ 88 (-68.12%)
Mutual labels:  mesh-networks, p2p
p2p-git-portal-poc
p2p git portal proof-of-concept using Svelte Golang/WASM (experimental)
Stars: ✭ 29 (-89.49%)
Mutual labels:  p2p, wasm
Gossamer
πŸ•ΈοΈ Gossamer: A Go implementation of the Polkadot Host (WIP)
Stars: ✭ 207 (-25%)
Mutual labels:  p2p, wasm
rust-monaco
Rust WASM bindings for the Monaco Editor
Stars: ✭ 23 (-91.67%)
Mutual labels:  wasm, wasm-bindgen
Spruce Network
Decentralized peer-to-peer mesh network.
Stars: ✭ 61 (-77.9%)
Mutual labels:  mesh-networks, p2p
Flatend
Quickly build microservices using p2p networking in NodeJS/Go.
Stars: ✭ 600 (+117.39%)
Mutual labels:  mesh-networks, p2p
Seed
A Rust framework for creating web apps
Stars: ✭ 3,069 (+1011.96%)
Mutual labels:  wasm, wasm-bindgen
Prototype Cjdns Pi
Prototype system for mesh networks on single board computers
Stars: ✭ 205 (-25.72%)
Mutual labels:  mesh-networks, p2p
rust-wasm-on-lambda-edge
Rust/WASM on AWS Lambda@Edge (CloudFront)
Stars: ✭ 12 (-95.65%)
Mutual labels:  wasm, wasm-bindgen
Fluence
Peer-to-peer computing protocol and licensing system
Stars: ✭ 453 (+64.13%)
Mutual labels:  p2p, wasm
wasm-bindgen-webcam-stream
A small example on how to get webcam stream on rust-wasm
Stars: ✭ 11 (-96.01%)
Mutual labels:  wasm, wasm-bindgen
Client
An alternative Polkadot Runtime Environment implementation acting as a full-node (excluding block production for validators) for syncing with Substrate-based chains.
Stars: ✭ 82 (-70.29%)
Mutual labels:  p2p, wasm
Decentralized Internet
A SDK/library for decentralized web and distributing computing projects
Stars: ✭ 406 (+47.1%)
Mutual labels:  mesh-networks, p2p
Berkanansdk
Bluetooth mesh messaging SDK for apps
Stars: ✭ 150 (-45.65%)
Mutual labels:  mesh-networks, p2p
Awesome Mesh
This is a list for mesh networking: Documentation, Free Software mesh protocols, and applications. A mesh network is a network topology in which each node relays data for the network. All mesh nodes cooperate in the distribution of data in the network.
Stars: ✭ 227 (-17.75%)
Mutual labels:  mesh-networks, p2p
torrent-spider
基于DHTηš„p2pη½‘η»œθ΅„ζΊηˆ¬θ™«
Stars: ✭ 65 (-76.45%)
Mutual labels:  p2p

Matchbox

crates.io MIT/Apache 2.0 crates.io docs.rs

Painless peer-to-peer WebRTC networking for rust wasm applications.

The goal of the Matchbox project is to enable udp-like, unordered, unreliable p2p connections in web browsers to facilitate low-latency multiplayer games.

WARNING: This project is in early stages, it will break as things are cleaned up and moved around.

It is currently an all-in-one solution, it comes with:

  • A tiny signalling server, matchbox_server. Written in rust, uses only a couple of megabytes of memory. Also available as a docker image.
  • An example browser game, using bevy, bevy_ggrs, matchbox_demo
  • A socket abstraction for rust wasm, matchbox_socket
    • With a feature, ggrs-socket for providing a ggrs compatible socket.

Live demo

Open each link in a separate browser window (or machine).

When enough players have joined, you should see a couple of boxes, one of which you can move around using the WASD keys.

You can open the browser console to get some rough idea about what's happening (or not happening if that's the unfortunate case).

How it works

WebRTC allows direct connections between peers, but in order to establish those connections, some kind of signalling service is needed. matchbox_server is such a service. Once the connections are established, however, data will flow directly between peers, and no traffic will go through the signalling server.

The signalling service needs to run somewhere all clients can reach it over http or https connections. In production, this usually means the public internet.

When a client wants to join a p2p (mesh) network, it connects to the signalling service and provides a room id. The signalling server then notifies the peers that have already connected about the new peer (sends a new_peer event).

The existing peers then send back WebRTC connection offers through the signalling service to the new client, each of which the new client responds with an "answer". Once the peers have enough information about each other, a WebRTCPeerConnection is established for each peer, and an unreliable, unordered data channel is opened.

All of this, however, is hidden from rust application code. All you will need to do on the client side, is:

  • Create a new socket, and give it a signalling server url and a room id
  • .await the message loop future that processes new messages. If you are using Bevy, it can be spawned as a Bevy io task (see matchbox_demo). See matchbox_simple_demo for usage with wasm-bindgen-futures. Alternatively, the future can be polled manually (at least once per frame).

You will then get notified whenever a new peer data connection has been established, and you will get all packets from peers in a single channel. Packets include a boxed u8 slice and the corresponding client's id.

Similarly, you can send packets to clients using a simple non-blocking method.

Next rooms

matchbox_server supports a rudimentary form of matchmaking. By appending ?next=3 to the room id, the next three players to join will be connected, and then the next three players will be connected separately to the first three.

You can also use the room id for scoping what kind of players you want to match. i.e.:

wss://match.example.com/awesome_game_v1.1.0_pvp?next=2

Showcase

Projects using Matchbox:

Thanks!

  • A huge thanks to Ernest Wong for his Dango Tribute experiment! matchbox_socket is heavily inspired its wasm-bindgen server_socket and Matchbox would probably not exist without it.

License

All code in this repository dual-licensed under either:

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].