Quickstart
A host opens a session and shows a QR code. A phone scans it, and what the person does with it arrives on the host as a message on a channel you named.
1. Install
npm install @bitskiff/host
@bitskiff/host is the host side -- a browser page, an Electron app, a signage player. The phone side
is a separate install you do not need yet: a new project's join code opens our sample phone page.
2. Get a key
In the console, create a project and then a publishable key (mrc_pk_...). It is meant for page
source, and a new one already allows http://localhost, so nothing else has to be set up first.
3. Open a session
import { BitskiffHost, qrSvg } from '@bitskiff/host';
const session = await new BitskiffHost({ key: 'mrc_pk_...' }).open();
const qr = qrSvg(session.joinCode.url); // an SVG string to put on your page
const press = session.channel('press'); // a channel is a name you wrote
const readout = session.channel('readout');
press.on('message', (m) => { // only `press` reaches this handler
readout.send(m.from.id, `pressed ${m.data}`); // a message is a string or bytes
});
4. Scan it
Put that QR where a camera can see it and scan it. It opens the sample phone page, and a press on it lands in your handler while the line you sent back shows on the phone.
Everything past that round trip is your own two halves: the names on the channels are yours, and nothing in the middle reads what you send.
Next
- Channels
- Lifecycle
- Your own phone page
- Node hosts
- Without a bundler
- @bitskiff/host -- reference
- @bitskiff/client -- reference