@@ -12,8 +12,12 @@ const taskplaner = {
12
12
addTask : async ( task : string ) : Promise < any > => {
13
13
return new Promise ( ( resolve , reject ) => {
14
14
cbws . getWebsocket . send ( JSON . stringify ( {
15
- "type" : "addTask" ,
16
- "task" : task
15
+ "type" : "taskEvent" ,
16
+ "action" :"addTask" ,
17
+ message :{
18
+ "task" : task
19
+ }
20
+
17
21
} ) ) ;
18
22
cbws . getWebsocket . on ( 'message' , ( data : string ) => {
19
23
const response = JSON . parse ( data ) ;
@@ -30,7 +34,8 @@ const taskplaner = {
30
34
getTasks : async ( ) : Promise < any > => {
31
35
return new Promise ( ( resolve , reject ) => {
32
36
cbws . getWebsocket . send ( JSON . stringify ( {
33
- "type" : "getTasks"
37
+ "type" :"taskEvent" ,
38
+ "action" : "getTasks"
34
39
} ) ) ;
35
40
cbws . getWebsocket . on ( 'message' , ( data : string ) => {
36
41
const response = JSON . parse ( data ) ;
@@ -39,6 +44,28 @@ const taskplaner = {
39
44
}
40
45
} ) ;
41
46
} ) ;
47
+ } ,
48
+ /**
49
+ * Updates an existing task using a WebSocket message.
50
+ * @param {string } task - The updated task information.
51
+ * @returns {Promise<any> } A promise that resolves with the response from the update task event.
52
+ */
53
+ updateTask : async ( task : string ) : Promise < any > => {
54
+ return new Promise ( ( resolve , reject ) => {
55
+ cbws . getWebsocket . send ( JSON . stringify ( {
56
+ "type" : "taskEvent" ,
57
+ "action" : "updateTask" ,
58
+ message : {
59
+ "task" : task
60
+ }
61
+ } ) ) ;
62
+ cbws . getWebsocket . on ( 'message' , ( data : string ) => {
63
+ const response = JSON . parse ( data ) ;
64
+ if ( response . type === "updateTaskResponse" ) {
65
+ resolve ( response ) ; // Resolve the promise with the response data from updating the task
66
+ }
67
+ } ) ;
68
+ } ) ;
42
69
}
43
70
} ;
44
71
0 commit comments