🔗 p2p

Shared WebRTC signaling for the browser games on santrancisco.net. Players on the same network find each other automatically; game traffic flows directly between devices.

import { joinRoom } from 'https://p2p.santrancisco.net/p2p.js?v=1';

const room = await joinRoom({ app: 'mygame', name: 'Alex' });       // same network
// const room = await joinRoom({ app: 'mygame', name: 'Alex', code: 'ABCD' });

room.on('peer-join', ({ peer }) => console.log(peer.name, 'joined'));
room.on('message', ({ from, data }) => console.log(from, data));
room.broadcast({ hello: 'world' });

Used by Blind Hot Potato.