UNPKG

@interactify-live/short

Version:

Pure MQTT connector for Interactify short videos - no UI or video dependencies

77 lines (76 loc) 2.04 kB
interface ConnectOptions { user_id: string; token: string; scope: "short" | "live"; space_slug: string; slug: string; session: string; brokerUrl?: string; } export interface ShortMessage { avatar: string; text: string; created_at: string; user_id: string; display_name: string; live_slug: string; space_slug: string; visible: boolean; slug: string; reply_to?: { text: string; user_id: string; display_name: string; }; } declare class Observable<T> { private callbacks; private value; constructor(value: T); set(value: T): this; get(): T; subscribe(callback: (value: T) => void): () => this; destroy(): void; } export declare class Connector { private client?; private tempClient?; private options?; static readonly CONNECTION_STATUS: { readonly CONNECTING: "CONNECTING"; readonly RECONNECTING: "RECONNECTING"; readonly CONNECTED: "CONNECTED"; readonly OFFLINE: "OFFLINE"; readonly ERROR: "ERROR"; }; private _status; get status(): Observable<"CONNECTING" | "RECONNECTING" | "CONNECTED" | "OFFLINE" | "ERROR">; private _messages; get messages(): Observable<ShortMessage[]>; private getTopics; private onMessageReceived; /** * Safely remove the 'message' listener from an MQTT client instance. * Different client builds may expose different APIs (removeListener/off/removeEventListener). */ private removeMessageListenerSafe; /** * Safely unsubscribe from topics if supported by the client. */ private unsubscribeSafe; connect(options: ConnectOptions): void; disconnect(): void; publish(type: string): void; sendMessage(message: { text: string; avatar?: string; displayName?: string; visible?: boolean; replyTo?: { text: string; userID: string; displayName: string; }; }): void; } export {};