@@ -8,8 +8,8 @@ const Switcher = dgram.createSocket('udp4');
88
99/** Handle errors and close Socket */
1010Switcher . on ( 'error' , ( err ) => {
11- console . log ( `Server error:\n${ err . stack } ` ) ;
12- Switcher . close ( ) ;
11+ console . log ( `Server error:\n${ err . stack } ` ) ;
12+ Switcher . close ( ) ;
1313} ) ;
1414
1515/**
@@ -153,19 +153,18 @@ function broadcast(broadcastMessage: string) {
153153
154154/** Launch UDP Socket and HTTP Servers, and listen on given port */
155155try {
156- Switcher . on ( 'listening' , ( ) : void => {
157- const address = Switcher . address ( ) ;
158- console . log ( `Switcher Server listening ${ address . address } :${ address . port } ` ) ;
159- } ) ;
160-
161- Switcher . bind ( socketPort , ( ) : void => {
162- // setInterval(() => {
163- // broadcast('Swticher is active')
164- // console.log(Routers)
165- // }, 5000)
166- console . log ( `Switcher UDP Datagram Server is active at ws://localhost:${ socketPort } ` ) ;
167- } ) ;
168-
169- } catch ( error : any ) {
170- console . error ( `An error occurred with starting Server ${ error . toString ( ) } ` ) ;
171- }
156+ const address = Switcher . address ( ) ;
157+ console . log ( `Switcher Server listening ${ address . address } :${ address . port } ` ) ;
158+ } ) ;
159+
160+ Switcher . bind ( socketPort , ( ) : void => {
161+ // setInterval(() => {
162+ // broadcast('Swticher is active')
163+ // console.log(Routers)
164+ // }, 5000)
165+ console . log ( `Switcher UDP Datagram Server is active at ws://localhost:${ socketPort } ` ) ;
166+ } ) ;
167+
168+ } catch ( error : any ) {
169+ console . error ( `An error occurred with starting Server ${ error . toString ( ) } ` ) ;
170+ }
0 commit comments