import { Channel } from 'phoenix'; import { ChannelId, ChatpiPresence, ConnectionConfig, SendOptions, SendReactionOptions } from './types'; /** * ## Chatpi Connection * * * Wrapped Channel Obj around a phoenix socket * * @typedef {Object} Connection~chatpi-client * @property {Channel} channel * @property {Array} presences */ export declare class Connection { private apiKey; private socket; private channels; private presences; private onPresenceChange; private onMessageReceive; private typingTimeout; private timeouts; /** * @remarks creates a connection with channelIds, default typing timoute is 10 seconds * @example Connect via apiKey * const connection = new Connection({ url, apiKey, channelIds, userToken, authorizationToken, onPresenceChange, typingTimeout, // initial messages you want returned, before/after a message timestamp //if you've never quered for messages before, just query before date.now messageQuery, }); */ constructor(config: ConnectionConfig); private createChannel; /** * send a message * @example Join a channel * sendMessage({ channel: 'cf4aeae1-cda7-41f3-adf7-9b2bb377be7d4', message }) .then((response) => console.log(response)); * */ sendMessage({ channelId, message }: SendOptions): Promise; /** * send a reaction * @example Join a channel * sendMessage({ channel: 'cf4aeae1-cda7-41f3-adf7-9b2bb377be7d4', message }) .then((response) => console.log(response)); * */ sendReaction({ channelId, reactionTargetId, classifier, }: SendReactionOptions): Promise; getChannelById(channelId: ChannelId): Channel; joinChannel(channelId: ChannelId): void; leaveChannel(channelId: ChannelId): void; startTyping(channelId: ChannelId): void; stopTyping(channelId: ChannelId): void; getPresenceById(channelId: ChannelId): ChatpiPresence; watchPresence(channelId: ChannelId): void; removePresenceWatcher(channelId: ChannelId): void; disconnect(): void; }