diff --git a/src/managers/ChatManager.ts b/src/managers/ChatManager.ts index 8347a164..58f3e738 100644 --- a/src/managers/ChatManager.ts +++ b/src/managers/ChatManager.ts @@ -5,13 +5,26 @@ import Base from '../Base'; import UserNotFoundError from '../exceptions/UserNotFoundError'; import type { ChatMessagePayload } from '../../resources/structs'; +// private scope const generateCustomCorrelationId = () => `EOS-${Date.now()}-${randomUUID()}`; +/** + * Represent's the client's chat manager (dm, party chat) via eos. + */ class ChatManager extends Base { - private get namespace() { + /** + * Returns the chat namespace, this is the eos deployment id + */ + public get namespace() { return this.client.config.eosDeploymentId; } + /** + * Sends a private message to the specified user + * @param user the account id or displayname + * @param message the message object + * @returns the message id + */ public async whisperUser(user: string, message: ChatMessagePayload) { const accountId = await this.client.user.resolveId(user); @@ -36,6 +49,13 @@ class ChatManager extends Base { return correlationId; } + /** + * Sends a message in the specified conversation (party chat) + * @param conversationId the conversation id, usually `p-[PARTYID]` + * @param message the message object + * @param allowedRecipients the account ids, that should receive the message + * @returns the message id + */ public async sendMessageInConversation(conversationId: string, message: ChatMessagePayload, allowedRecipients: string[]) { const correlationId = generateCustomCorrelationId(); diff --git a/src/stomp/EOSConnect.ts b/src/stomp/EOSConnect.ts index 29ab9627..096a45ba 100644 --- a/src/stomp/EOSConnect.ts +++ b/src/stomp/EOSConnect.ts @@ -1,4 +1,3 @@ -/* eslint-disable no-console */ import { Client as StompClient, Versions } from '@stomp/stompjs'; import WebSocket, { type ErrorEvent } from 'ws'; import Base from '../Base'; @@ -50,6 +49,9 @@ class EOSConnect extends Base { return this.stompConnectionId; } + /** + * connect to the eos connect stomp server + */ public async connect() { if (!this.client.auth.sessions.has(AuthSessionStoreKey.FortniteEOS)) { throw new AuthenticationMissingError(AuthSessionStoreKey.FortniteEOS); @@ -123,6 +125,11 @@ class EOSConnect extends Base { this.client.debug('[STOMP EOS Connect] Disconnected'); } + /** + * Sets up the subscription for the deployment + * @param connectionResolve connect promise resolve + * @param connectionReject connect promise reject + */ private setupSubscription(connectionResolve: (value: unknown) => void, connectionReject: (reason?: unknown) => void) { this.stompConnection!.subscribe( `${this.client.config.eosDeploymentId}/account/${this.client.user.self!.id}`, diff --git a/src/xmpp/XMPP.ts b/src/xmpp/XMPP.ts index cb2f66f1..973aad5a 100644 --- a/src/xmpp/XMPP.ts +++ b/src/xmpp/XMPP.ts @@ -671,6 +671,7 @@ class XMPP extends Base { * @param to The message receiver's JID * @param content The message that will be sent * @param type The message type (eg "chat" or "groupchat") + * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat} */ public async sendMessage(to: string, content: string, type: Constants.MessageType = 'chat') { return this.waitForSentMessage(this.connection!.sendMessage({ @@ -684,6 +685,7 @@ class XMPP extends Base { * Wait until a message is sent * @param id The message id * @param timeout How long to wait for the message + * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat} */ public waitForSentMessage(id: string, timeout = 1000) { return new Promise((res) => { @@ -710,6 +712,7 @@ class XMPP extends Base { * Joins a multi user chat room (MUC) * @param jid The room's JID * @param nick The client's nickname + * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat} */ public async joinMUC(jid: string, nick: string) { return this.connection!.joinRoom(jid, nick); @@ -719,6 +722,7 @@ class XMPP extends Base { * Leaves a multi user chat room (MUC) * @param jid The room's JID * @param nick The client's nickname + * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat} */ public async leaveMUC(jid: string, nick: string) { return this.connection!.leaveRoom(jid, nick); @@ -727,6 +731,7 @@ class XMPP extends Base { /** * Bans a member from a multi user chat room * @param member The member that should be banned + * @deprecated this is useless now, since chat messages are handeled via an rest api now see {@link Client#chat} */ public async ban(jid: string, member: string) { return this.connection!.ban(jid, `${member}@${Endpoints.EPIC_PROD_ENV}`);