Skip to content

Commit d6ba2d2

Browse files
get state added
1 parent 4431e5b commit d6ba2d2

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-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.12",
3+
"version": "1.1.13",
44
"description": "",
55
"keywords": [],
66
"author": "",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import cboutputparsers from './modules/outputparsers';
1515
import cbproject from './modules/project';
1616
import git from './modules/git';
1717
import dbmemory from './modules/dbmemory';
18+
import cbstate from './modules/state'
1819
import WebSocket from 'ws';
1920

2021
/**
@@ -87,6 +88,7 @@ class Codebolt {
8788
outputparsers = cboutputparsers;
8889
project = cbproject;
8990
dbmemory = dbmemory;
91+
cbstate=cbstate;
9092
}
9193

9294
// export default new Codebolt();

src/modules/state.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import cbws from './websocket';
2+
3+
4+
const cbstate = {
5+
getApplicationState: async (): Promise<any> => {
6+
return new Promise((resolve, reject) => {
7+
cbws.getWebsocket.send(JSON.stringify({
8+
"type": "getAppState",
9+
10+
}));
11+
cbws.getWebsocket.on('message', (data: string) => {
12+
const response = JSON.parse(data);
13+
if (response.type === "getAppStateResponse") {
14+
resolve(response); // Resolve the Promise with the response data
15+
}
16+
});
17+
});
18+
}
19+
};
20+
21+
export default cbstate;
22+

0 commit comments

Comments
 (0)