UNPKG

@iotize/tap

Version:

IoTize Device client for Javascript

48 lines (47 loc) 1.8 kB
import { EncryptionAlgo, TapClientInterface, TapRequestFrame, TapResponseFrame } from '@iotize/tap/client/api'; import { TapClient } from '@iotize/tap/client/impl'; import { Observable, Subject } from 'rxjs'; import { Predicate } from './definitions'; import { MockRouter } from './mock-router'; /** * Mock client options to configure fake delay for connect/disconnect and send operations */ export interface MappingType { [key: string]: TapResponseFrame; } export declare type TapRequestFilter = Predicate<TapRequestFrame> | ((request: TapRequestFrame) => boolean); export declare function createMockClient(options?: { connected?: boolean; }): MockClient; export declare namespace MockClient { interface InstanceOptions { isConnected: boolean; connect: { delay: number; }; disconnect: { delay: number; }; command: { delay: number; timeout: number; }; encryption: boolean; } } export declare class MockClient extends TapClient implements TapClientInterface { router: MockRouter; static DEFAULT_OPTIONS: MockClient.InstanceOptions; input: Subject<TapRequestFrame>; output: Subject<TapResponseFrame>; options: MockClient.InstanceOptions; isConnected(): boolean; encryptionAlgo?: EncryptionAlgo; constructor(options?: Partial<MockClient.InstanceOptions>, router?: MockRouter); static createWithMockProtocol(): MockClient; connect(): Observable<any>; disconnect(): Observable<any>; mockResponse(tapResponse: TapResponseFrame): void; request<T>(request: TapRequestFrame): Observable<TapResponseFrame>; protected computeResponse(cmd: TapRequestFrame): TapResponseFrame; }