File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ export class SocketServer {
2525
2626 private server : HttpServer ;
2727 private connectionSecret : string ;
28+ private startTimestamp = new Date ( ) ;
2829 private mainConnections = new Map < string , WebSocket > ( ) ; // These are per webpage
2930 private sessions = new Map < string , Session > ( ) ;
3031
@@ -124,7 +125,14 @@ export class SocketServer {
124125 private handleClientConnected = ( ws : WebSocket ) => {
125126 const clientId = uuid ( ) ;
126127 this . mainConnections . set ( clientId , ws ) ;
127- ws . send ( JSON . stringify ( { key : 'opened' , data : { clientId } } ) )
128+ ws . send ( JSON . stringify ( { key : 'opened' , data : { clientId, startTimestamp : this . startTimestamp . toISOString ( ) } } ) ) ;
129+
130+ ws . on ( 'message' , ( message ) => {
131+ const data = JSON . parse ( message . toString ( 'utf8' ) ) ;
132+ if ( data . key === 'terminate' ) {
133+ process . exit ( 0 ) ;
134+ }
135+ } ) ;
128136
129137 ws . on ( 'close' , ( ) => {
130138 this . mainConnections . delete ( clientId ) ;
You can’t perform that action at this time.
0 commit comments