createClient(options: ClientOptions): Client
Creates a Baichuan client over the given connection streams.
Requests are matched to replies by command, channel and message id, so calls may overlap. Messages that match no request are pushes: cmd 33 pushes feed the event stream, all others are dropped.
Log in and subscribe
Log in and subscribe
import { createClient } from "@hertzg/reolink-api/client"; const conn = await Deno.connect({ hostname: "192.168.1.10", port: 9000 }); const client = createClient({ readable: conn.readable, writable: conn.writable }); await client.login({ username: "admin", password: "secret" }); const events = await client.subscribe({ keepAliveMs: 20_000 }); for await (const event of events) { if (event.visitor) { console.log("doorbell active on channel", event.channel); } } await client.close(); conn.close();
options: ClientOptions
The connection's readable and writable streams.