@@ -12,8 +12,12 @@ const taskplaner = {
1212 addTask : async ( task : string ) : Promise < any > => {
1313 return new Promise ( ( resolve , reject ) => {
1414 cbws . getWebsocket . send ( JSON . stringify ( {
15- "type" : "addTask" ,
16- "task" : task
15+ "type" : "taskEvent" ,
16+ "action" :"addTask" ,
17+ message :{
18+ "task" : task
19+ }
20+
1721 } ) ) ;
1822 cbws . getWebsocket . on ( 'message' , ( data : string ) => {
1923 const response = JSON . parse ( data ) ;
@@ -30,7 +34,8 @@ const taskplaner = {
3034 getTasks : async ( ) : Promise < any > => {
3135 return new Promise ( ( resolve , reject ) => {
3236 cbws . getWebsocket . send ( JSON . stringify ( {
33- "type" : "getTasks"
37+ "type" :"taskEvent" ,
38+ "action" : "getTasks"
3439 } ) ) ;
3540 cbws . getWebsocket . on ( 'message' , ( data : string ) => {
3641 const response = JSON . parse ( data ) ;
@@ -39,6 +44,28 @@ const taskplaner = {
3944 }
4045 } ) ;
4146 } ) ;
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+ } ) ;
4269 }
4370} ;
4471
0 commit comments