UNPKG

@ethora/chat-component

Version:

1. npm create vite@latest 2. select name of project, select type (react/js) 3. cd project-name 4. npm i 5. npm i @ethora/chat-component 6. go to file src/App.tsx and replace it with this code

86 lines (85 loc) 4.15 kB
import { Client } from '@xmpp/client'; import { Iso639_1Codes, XmppClientInterface, xmppSettingsInterface, IMessage } from '../types/types'; export declare class XmppClient implements XmppClientInterface { client: Client; devServer: string | undefined; host: string; service: string; conference: string; username: string; status: string; resource: string; password: string; reconnectAttempts: number; maxReconnectAttempts: number; reconnectDelay: number; private reconnecting; private reconnectPromise; presencesReady: boolean; private connectionSteps; private messageQueue; private inFlightIds; private processingQueue; checkOnline(): boolean; pingInterval: any; pingTimeout: any; lastPingId: string | null; pingIntervalMs: number; pongTimeoutMs: number; pingOnSendEnabled: boolean; idleThresholdMs: number; lastActivityTs: number; pingInFlight: boolean; private idlePingTimeout; constructor(username: string, password: string, xmppSettings?: xmppSettingsInterface); initializeClient(): Promise<void>; disconnect(): Promise<void>; attachEventListeners(): void; private scheduleAdaptivePing; private startAdaptivePing; private markActivity; sendAllPresencesAndMarkReady(): Promise<void>; reconnect(): Promise<void>; allRoomPresencesStanza(): Promise<void>; ensureConnected(timeout?: number): Promise<void>; close(): Promise<void>; wrapWithConnectionCheck<T>(operation: () => Promise<T>): Promise<T>; private enqueue; private processQueue; private withIdLock; private onBrowserOnline; private onBrowserOffline; getConnectionSteps(): Array<{ ts: number; step: string; }>; private logStep; getRoomsStanza: (disableGetRooms?: boolean) => Promise<void>; getRoomsPagedStanza(maxResults?: number, after?: string | null): Promise<void>; createRoomStanza(title: string, description: string): Promise<string>; inviteRoomRequestStanza(to: string, roomJid: string): Promise<void>; leaveTheRoomStanza: (roomJID: string) => void; presenceInRoomStanza: (roomJID: string, settleDelay?: number) => Promise<void>; getHistoryStanza: (chatJID: string, max: number, before?: number, otherStanzaId?: string) => Promise<IMessage[]>; getLastMessageArchiveStanza(roomJID: string): void; setRoomImageStanza: (roomJid: string, roomThumbnail: string, type: string, roomBackground?: string) => void; getRoomInfoStanza: (roomJID: string) => void; getRoomMembersStanza: (roomJID: string) => void; setVCardStanza(xmppUsername: string): void; sendMessageWithPingCheck(sendFn: () => Promise<void>): Promise<boolean>; sendMessage: (roomJID: string, firstName: string, lastName: string, photo: string, walletAddress: string, userMessage: string, notDisplayedValue?: string, isReply?: boolean, showInChannel?: boolean, mainMessage?: string, customId?: string) => Promise<boolean>; sendTextMessageWithTranslateTagStanza: (roomJID: string, firstName: string, lastName: string, photo: string, walletAddress: string, userMessage: string, notDisplayedValue?: string, isReply?: boolean, showInChannel?: boolean, mainMessage?: string, langSource?: Iso639_1Codes, customId?: string) => Promise<boolean>; deleteMessageStanza(room: string, msgId: string): void; editMessageStanza(room: string, msgId: string, text: string): void; sendMessageReactionStanza(messageId: string, roomJid: string, reactionsList: string[], reactionSymbol?: any): void; sendTypingRequestStanza(chatId: string, fullName: string, start: boolean): void; getChatsPrivateStoreRequestStanza: () => Promise<unknown>; actionSetTimestampToPrivateStoreStanza(chatId: string, timestamp: number, chats?: string[]): Promise<void>; createPrivateRoomStanza(title: string, description: string, to: string): Promise<string>; sendMediaMessageStanza(roomJID: string, data: any, id: string): void; sendPingStanza(): void; handlePong(): void; handlePingTimeout(): void; private drainHeap; } export default XmppClient;