UNPKG

1.57 kBTypeScriptView Raw
1import { Transport } from '../enums';
2import { MqttClient } from '../external/mqtt-client.interface';
3import { CustomTransportStrategy, MessageHandler, PacketId, ReadPacket } from '../interfaces';
4import { MqttOptions } from '../interfaces/microservice-configuration.interface';
5import { Server } from './server';
6/**
7 * @publicApi
8 */
9export declare class ServerMqtt extends Server implements CustomTransportStrategy {
10 private readonly options;
11 readonly transportId = Transport.MQTT;
12 protected mqttClient: MqttClient;
13 private readonly url;
14 constructor(options: MqttOptions['options']);
15 listen(callback: (err?: unknown, ...optionalParams: unknown[]) => void): Promise<void>;
16 start(callback: (err?: unknown, ...optionalParams: unknown[]) => void): void;
17 bindEvents(mqttClient: MqttClient): void;
18 close(): void;
19 createMqttClient(): MqttClient;
20 getMessageHandler(pub: MqttClient): Function;
21 handleMessage(channel: string, buffer: Buffer, pub: MqttClient, originalPacket?: Record<string, any>): Promise<any>;
22 getPublisher(client: MqttClient, pattern: any, id: string): any;
23 parseMessage(content: any): ReadPacket & PacketId;
24 matchMqttPattern(pattern: string, topic: string): boolean;
25 getHandlerByPattern(pattern: string): MessageHandler | null;
26 removeHandlerKeySharedPrefix(handlerKey: string): string;
27 getRequestPattern(pattern: string): string;
28 getReplyPattern(pattern: string): string;
29 handleError(stream: any): void;
30 protected initializeSerializer(options: MqttOptions['options']): void;
31}