import { Decoder, Encoder } from '@iotize/common/converter/api'; import { ProtocolChangeEvent, RequestInterceptorType, TapClientInterface, TapRequestFrame, TapResponseFrame } from '@iotize/tap/client/api'; import { ComProtocol, ConnectionStateChangeEvent } from '@iotize/tap/protocol/api'; import { Observable } from 'rxjs'; import { InterceptorChain } from './interceptors/interceptor-chain'; export declare class TapClient implements TapClientInterface { private _commandEncoder; private _responseDecoder; private _onProtocolChange; private protocols; private currentProtocolId?; private _interceptorChain; static create(protocol?: ComProtocol): TapClient; constructor(requestEncoder: Encoder, responseDecoder: Decoder); get interceptorChain(): InterceptorChain; addInterceptor(interceptor: RequestInterceptorType): this; isConnected(): boolean; /** * see {@link getCurrentProtocol} */ get protocol(): ComProtocol; get commandEncoder(): Encoder; get responseDecoder(): Decoder, TapResponseFrame>; /** * Get current protocol or throw an error if no protocol */ getCurrentProtocol(): ComProtocol; /** * Register/replace a communication protocol with given id * If no communication protocol is selected yet, it will select it. * @param newProtocol * @param id */ addComProtocol(newProtocol: ComProtocol, id?: string): this; /** * Switch to given communication protocol identifier * @throws if protocol identifier does not exist * @param name */ switchProtocol(name: string): this; /** * Change communication protocol * @throws if protocol identifier does not exist * @param protocol can either be the communication protocol instance or a string identifier */ useComProtocol(protocol: ComProtocol | string): this; /** * Return true if protocol identifier is registered * @param id */ hasProtocol(id: any): boolean; connect(): Observable; disconnect(): Observable; /** * Send request * @param request * @param bodyDecoder */ request(request: TapRequestFrame): Observable; /** * Send raw request * No interceptors/No encryption will be triggered * @param dataIn request bytes * @param bodyDecoder optional body decoder to use */ send(dataIn: Uint8Array): Observable; /** * Listen to connection state change event * We have to resubscribe when protocol change.. */ onConnectionStateChange(): Observable; onProtocolChange(): Observable; protected _command(command: TapRequestFrame): Observable; }