@codebolt/codeboltjs 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/modules/chat.d.ts CHANGED
@@ -10,6 +10,7 @@ declare class CustomEventEmitter extends EventEmitter {
10
10
  */
11
11
  declare const cbchat: {
12
12
  eventEmitter: CustomEventEmitter;
13
+ getChatHistory(): Promise<unknown>;
13
14
  /**
14
15
  * Sends a message through the WebSocket connection.
15
16
  * @param {string} message - The message to be sent.
package/modules/chat.js CHANGED
@@ -16,6 +16,19 @@ class CustomEventEmitter extends events_1.EventEmitter {
16
16
  */
17
17
  const cbchat = {
18
18
  eventEmitter: new CustomEventEmitter(),
19
+ getChatHistory() {
20
+ return new Promise((resolve, reject) => {
21
+ websocket_1.default.getWebsocket.send(JSON.stringify({
22
+ "type": "getChatHistory"
23
+ }));
24
+ websocket_1.default.getWebsocket.on('message', (data) => {
25
+ const response = JSON.parse(data);
26
+ if (response.type === "getChatHistoryResponse") {
27
+ resolve(response); // Resolve the Promise with the response data
28
+ }
29
+ });
30
+ });
31
+ },
19
32
  /**
20
33
  * Sends a message through the WebSocket connection.
21
34
  * @param {string} message - The message to be sent.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codebolt/codeboltjs",
3
- "version": "1.1.10",
3
+ "version": "1.1.12",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -13,6 +13,22 @@ class CustomEventEmitter extends EventEmitter {}
13
13
  const cbchat = {
14
14
  eventEmitter: new CustomEventEmitter(),
15
15
 
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
+
16
32
  /**
17
33
  * Sends a message through the WebSocket connection.
18
34
  * @param {string} message - The message to be sent.