import { Logger, LogOptions } from "@alterior/logging"; import { ChatMessage, CommentsOrder, FilterMode, RPCMessage, SocketRPC, Topic, User } from "@banta/common"; import { ChatService, PinOptions } from "./chat.service"; export declare class ChatConnection extends SocketRPC { readonly id: string; readonly chat: ChatService; readonly ipAddress: string | undefined; readonly userAgent: string | undefined; private logger; constructor(id: string, chat: ChatService, ipAddress: string | undefined, userAgent: string | undefined, logger: Logger); private subs; userToken: string | undefined; user: User | undefined; topicId: string | undefined; parentMessage: ChatMessage | null | undefined; readonly logContext: Record; readonly logContextLabel: string; protected onReceiveMessage(message: RPCMessage): Promise; bind(socket: WebSocket): Promise; getTopicInfo(topicId?: string): Promise<{ id: string; createdAt: number; description: string | undefined; url: string | undefined; messageCount: number; clientCount: number; }>; getServerInfo(): Promise<{ service: string; serverId: string; originId: string; connections: number; cache: { topicCount: number; messageCount: number; topics: { [k: string]: number; }; }; }>; authenticate(token: string): Promise; private precheckAuthorization; private sendPermissions; /** * Send the chat message to the client. This does not mean "the user is sending a message". * This is called whenever a new or updated message needs to ber sent to the client for use. * @param message */ private sendChatMessage; private prepareMessage; topic: Topic | null | undefined; get canUseCache(): boolean; /** * Load the messages that were sent after the previous disconnect, used for short disconnects. * This only works in some scenarios where it is performant (namely cacheable cases like Newest/All) * * Clients should not call this if the disconnect period was extensive (ie more than a few minutes). * In that case it would be more efficient to just call getExistingMessages() directly. * * TODO: this is not yet used * * @param id */ loadSince(id: string): Promise; loadAfter(messageIndex: number, count: number): Promise; editMessage(messageId: string, newText: string): Promise; sortOrder: CommentsOrder; filterMode: FilterMode; /** * Arbitrary metadata provided by the client. This is ignored by Banta. */ metadata: Record; deleteMessage(messageId: string): Promise; /** * Subscribe to a topic. A Banta connection may only connect to a single source at a time. After subscribing, the * messageReceived event will be fired with the backlog of messages as well as for all new messages received. * * @param topicId The topic to subscribe to * @param parentMessageId The message within the topic to subscribe to (for replies), or undefined for top level messages * @param order The desired order to receive messages * @param filterMode Filter to use when receiving messages * @param metadata Arbitrary metadata which can be passed from the frontend to the application-specific backend. Banta ignores this. */ subscribe(topicId: string, parentMessageId: string | undefined, order: CommentsOrder, filterMode: FilterMode, metadata?: Record): Promise; private ownsMessage; log(message: string, options?: LogOptions, alwaysLog?: boolean): void; logInfoAlways(message: string): void; logInfo(message: string): void; logError(message: string): void; logFatal(message: string): void; logWarning(message: string): void; getPinnedMessages(limit?: number): Promise; getExistingMessages(limit?: number): Promise; private getFilter; private getSortOrder; pinMessage(messageId: string, options?: PinOptions): Promise; unpinMessage(messageId: string): Promise; sendMessage(message: ChatMessage): Promise; getMessage(id: string): Promise; likeMessage(id: string): Promise; unlikeMessage(id: string): Promise; }