@codebolt/codeboltjs 1.1.43 → 1.1.44
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/index.d.ts +1 -0
- package/modules/chat.d.ts +5 -0
- package/modules/chat.js +18 -0
- package/package.json +1 -1
- package/src/modules/chat.ts +19 -0
package/index.d.ts
CHANGED
package/modules/chat.d.ts
CHANGED
|
@@ -44,5 +44,10 @@ declare const cbchat: {
|
|
|
44
44
|
* Sends a specific message to the server to stop the process.
|
|
45
45
|
*/
|
|
46
46
|
stopProcess: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Sends a confirmation request to the server with two options: Yes or No.
|
|
49
|
+
* @returns {Promise<string>} A promise that resolves with the server's response.
|
|
50
|
+
*/
|
|
51
|
+
sendConfirmationRequest: (confirmationMessage: string) => Promise<string>;
|
|
47
52
|
};
|
|
48
53
|
export default cbchat;
|
package/modules/chat.js
CHANGED
|
@@ -125,6 +125,24 @@ const cbchat = {
|
|
|
125
125
|
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
126
126
|
"type": "processStoped"
|
|
127
127
|
}));
|
|
128
|
+
},
|
|
129
|
+
/**
|
|
130
|
+
* Sends a confirmation request to the server with two options: Yes or No.
|
|
131
|
+
* @returns {Promise<string>} A promise that resolves with the server's response.
|
|
132
|
+
*/
|
|
133
|
+
sendConfirmationRequest: (confirmationMessage) => {
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
websocket_1.default.getWebsocket.send(JSON.stringify({
|
|
136
|
+
"type": "confirmationRequest",
|
|
137
|
+
"message": confirmationMessage
|
|
138
|
+
}));
|
|
139
|
+
websocket_1.default.getWebsocket.on('message', (data) => {
|
|
140
|
+
const response = JSON.parse(data);
|
|
141
|
+
if (response.type === "confirmationResponse") {
|
|
142
|
+
resolve(response.answer); // Resolve the Promise with the server's response
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
});
|
|
128
146
|
}
|
|
129
147
|
};
|
|
130
148
|
exports.default = cbchat;
|
package/package.json
CHANGED
package/src/modules/chat.ts
CHANGED
|
@@ -129,6 +129,25 @@ const cbchat = {
|
|
|
129
129
|
cbws.getWebsocket.send(JSON.stringify({
|
|
130
130
|
"type": "processStoped"
|
|
131
131
|
}));
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Sends a confirmation request to the server with two options: Yes or No.
|
|
136
|
+
* @returns {Promise<string>} A promise that resolves with the server's response.
|
|
137
|
+
*/
|
|
138
|
+
sendConfirmationRequest: (confirmationMessage: string): Promise<string> => {
|
|
139
|
+
return new Promise((resolve, reject) => {
|
|
140
|
+
cbws.getWebsocket.send(JSON.stringify({
|
|
141
|
+
"type": "confirmationRequest",
|
|
142
|
+
"message": confirmationMessage
|
|
143
|
+
}));
|
|
144
|
+
cbws.getWebsocket.on('message', (data: string) => {
|
|
145
|
+
const response = JSON.parse(data);
|
|
146
|
+
if (response.type === "confirmationResponse") {
|
|
147
|
+
resolve(response.answer); // Resolve the Promise with the server's response
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
132
151
|
}
|
|
133
152
|
};
|
|
134
153
|
|