File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change 11import WebSocket from 'ws' ;
2+ import fs from 'fs' ;
3+ import yaml from 'js-yaml' ;
24
35/**
46 * Class representing a WebSocket connection.
@@ -10,11 +12,23 @@ class cbws {
1012 * Constructs a new cbws instance and initializes the WebSocket connection.
1113 */
1214 constructor ( ) {
13- this . websocket = new WebSocket ( "ws://localhost:12345/codebolt" ) ;
15+ const uniqueConnectionId = this . getUniqueConnectionId ( ) ;
16+ console . log ( uniqueConnectionId )
17+ this . websocket = new WebSocket ( `ws://localhost:12345/codebolt?id=${ uniqueConnectionId } ` ) ;
1418 this . initializeWebSocket ( ) . catch ( error => {
1519 console . error ( "WebSocket connection failed:" , error ) ;
1620 } ) ;
1721 }
22+ private getUniqueConnectionId ( ) : string {
23+ try {
24+ let fileContents = fs . readFileSync ( './codebotagent.yml' , 'utf8' ) ;
25+ let data = yaml . safeLoad ( fileContents ) ;
26+ return data . uniqueConnectionId ;
27+ } catch ( e ) {
28+ console . log ( e ) ;
29+ return '' ;
30+ }
31+ }
1832
1933 /**
2034 * Initializes the WebSocket by setting up event listeners and returning a promise that resolves
You can’t perform that action at this time.
0 commit comments