import { Game } from "./game" ; import { SocketService } from "./routing/socket.service" ; import { fsm , Events } from "./controller" ; export class Server { constructor ( ) { let socket = SocketService . init ( ) ; console . log ( "Start Server" ) ; socket . onopen = ( ) => { console . log ( "Connected to Server" ) ; fsm . input ( Events . CONNECTED ) ; let pingLabel = document . getElementById ( "ping_label" ) ; setInterval ( ( ) => { SocketService . send ( "ping" , Date . now ( ) , ( data ) => { let ping = Date . now ( ) - data . ts ; pingLabel . innerHTML = ping + " ping (ms)" ; } ) ; } , 3000 ) ; } ; } }