UNPKG

@cygnus-reach/reach-protocol

Version:

Improve the Reachâ„  remote support experience with straightforward device interactions via the Reach Protocol.

32 lines (31 loc) • 1.59 kB
import { Observable, Subject } from 'rxjs'; import { ReachMessage } from './proto/reach'; /** * A class for managing communications between a Reach Protocol device (server) and client. * @remarks This should be implemented appropriately for the data transport method being used, such as BLE. */ export declare abstract class NetworkAccess { protected onMessageSubject: Subject<Uint8Array>; /** * Observable fired whenever new raw data is received from the Reach Protocol device (server). */ onMessage$: Observable<Uint8Array>; /** * Sends data to a Reach Protocol device (server). This method should return upon successful transmission of the data. * @param bytes - The raw bytes to be sent, generally containing a Reach Protocol message */ abstract sendBytes(bytes: Uint8Array): void | Promise<void | Uint8Array>; /** * Sends a provided Reach Protocol message to the device via the provided method for sending bytes. * @param message - The message to be sent to the device. * @param classicHeader - Whether the legacy "classic" header format should be used. Defaults to false. * @returns The return from the {@link sendBytes} function call */ send(message: ReachMessage, classicHeader?: boolean): void | Promise<void | Uint8Array>; /** * A method to be called whenever bytes are received from the Reach Protocol device (server). * These bytes are then parsed as a Reach Protocol message. * @param bytes - The raw bytes from the device */ received(bytes: Uint8Array): void; }