import {useNetwork} from './useNetwork' const short = (id: string) => id.slice(0, 8) + '…' + id.slice(-4) const time = (ms: number) => new Date(ms).toLocaleTimeString() export default function App() { const {snapshot, dispatch} = useNetwork() const {selfId, connectedAt, centralId, amCentral, roster, state, version} = snapshot return (
{short(selfId)}{centralId ? short(centralId) : '(none)'}
Commands are sent to the central peer, which updates the authoritative state and broadcasts it back to everyone.
| ID | Connected | Role |
|---|---|---|
{short(p.peerId)}
{p.isSelf ? ' (you)' : ''}
|
{time(p.connectedAt)} | {p.isCentral ? 'central' : 'peer'} |