Skip to content

Commit 9e2fd4f

Browse files
changes
1 parent 9156465 commit 9e2fd4f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/modules/chat.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ class CustomEventEmitter extends EventEmitter {}
1313
const cbchat = {
1414
eventEmitter: new CustomEventEmitter(),
1515

16+
getChatHistory() {
17+
return new Promise((resolve, reject) => {
18+
cbws.getWebsocket.send(JSON.stringify({
19+
"type": "getChatHistory"
20+
}));
21+
cbws.getWebsocket.on('message', (data: string) => {
22+
const response = JSON.parse(data);
23+
if (response.type === "getChatHistoryResponse") {
24+
resolve(response); // Resolve the Promise with the response data
25+
}
26+
})
27+
})
28+
29+
30+
}
31+
1632
/**
1733
* Sends a message through the WebSocket connection.
1834
* @param {string} message - The message to be sent.

0 commit comments

Comments
 (0)