UNPKG

@signalapp/mock-server

Version:
20 lines (19 loc) 724 B
import WebSocket from 'ws'; import { signalservice as SignalService } from '../../../protos/compiled'; export type WSRequest = SignalService.IWebSocketRequestMessage; export type WSResponse = SignalService.IWebSocketResponseMessage; interface RequestOptions { readonly body?: Uint8Array; readonly headers?: Array<string> | null; } export declare abstract class Service { protected readonly ws: WebSocket; private readonly requests; private lastSentId; constructor(ws: WebSocket); send(verb: string, path: string, options: RequestOptions): Promise<WSResponse>; private onMessage; private onClose; protected abstract handleRequest(request: WSRequest): Promise<WSResponse>; } export {};