Skip to content

Commit 3944d4f

Browse files
changes
1 parent ab1852b commit 3944d4f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codebolt/codeboltjs",
3-
"version": "1.1.43",
3+
"version": "1.1.44",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/modules/chat.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,25 @@ const cbchat = {
129129
cbws.getWebsocket.send(JSON.stringify({
130130
"type": "processStoped"
131131
}));
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+
});
132151
}
133152
};
134153

0 commit comments

Comments
 (0)