func (gh *game_hub) commitGame(game *game) { delete(gh.uncommittedGames, game.numPlayers) // make connection to server conn, err := connectToServer() if err != nil { logger.Fatalf("Could not connect to server, dying...") return } game.proxy.server = &serverConnection{conn: conn} game.channelInHandler(game.proxy) go game.proxy.serverReadPump() game.proxy.sendInitialGameInfo() logger.Info("Committed a game, proxying its messages") gh.committedGames.PushBack(game) }
func Main() { logger.SetupLogger(logger.DEBUG, logger.USUAL) setupGamehub() go gamehub.handleConnections() static_http.Handle("/", http.FileServer(http.Dir("./"))) http.HandleFunc("/", serveIndex) http.HandleFunc("/ws", serveWs) logger.Debug("Http server listening on port 8888") err := http.ListenAndServe(":8888", nil) if err != nil { logger.Fatalf("ListenAndServe: %s", err.Error()) } }