@interactify-live/short
Version:
Pure MQTT connector for Interactify short videos - no UI or video dependencies
95 lines (94 loc) • 2.54 kB
TypeScript
interface ConnectOptions {
user_id: string;
token: string;
scope: "short" | "live";
space_slug: string;
slug: string;
session: string;
display_name: string;
brokerUrl?: string;
}
export interface LikeEvent {
messageSlug: string;
user_id: string;
space_slug: string;
slug: string;
like_type?: "like" | "dislike";
}
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;
like_count?: number;
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;
slug: string;
avatar?: string;
created_at?: string;
short_slug?: string;
space_slug?: string;
visible?: boolean;
};
}): void;
sendLikeEvent(messageSlug: string, options?: {
like_type?: "like" | "dislike";
}): void;
}
export {};