@rainway/web
The Rainway SDK Web Runtime. For more information check out docs.rainway.com.
Usage
import rainway, { InputLevel } from "@rainway/web";
// handle rainway component log events
rainway.addEventListener("log", (level, target, message) => {
console.log(`[${level}] ${target} ${message}`);
});
// connect to Rainway services
const conn = await rainway.connect({apiKey: "YOUR_API_KEY" });
// obtain your id within the Rainway network
console.log(`Your peer id is ${conn.id}`);
// explicitly connect to another peer on the Rainway network using their id
const peer = await conn.connect(BigInt(12345678));
// attempt to create a stream between the peers, with permission to all input
const stream = await peer.createStream({ permissions: InputLevel.All });
// attach the stream to the element, it will automatically begin to play
document.appendChild(stream.container);
//
// additional application logic here
//
// shut down the stream
await stream.close();
// shut down the peer connection
await peer.close();
// shut down the rainway connection
await conn.close();