/** * Represents a group of games. * * Normally a group only has 1 game but * for situations where we need more than * 1 game ... * */ public HFTGameGroup(string gameId, HFTGameManager relayServer) { log_ = new HFTLog("HFTGameGroup[" + gameId + "]"); gameId_ = gameId; //this.runtimeInfo = gameDB.getGameById(gameId); relayServer_ = relayServer; }
public static HFTGameManager GetInstance() { if (s_instance == null) { s_instance = new HFTGameManager(); } return s_instance; }
static public HFTGameManager GetInstance() { if (s_instance == null) { s_instance = new HFTGameManager(); } return(s_instance); }
void HandleCmdPing(HttpListenerRequest req, HttpListenerResponse res) { // Yes reaching up this far is shit :( if (!HFTGameManager.GetInstance().HaveGame()) { res.StatusCode = (int)HttpStatusCode.NotFound; } m_webServerUtils.SendJsonBytes(res, m_ping); }
protected override void OnOpen() { log_.Info("open"); try { HFTGameManager.GetInstance().AddPlayer(this); } catch (System.Exception ex) { log_.Error(ex.StackTrace); } }
void HandleCmdPing(HttpListenerRequest req, HttpListenerResponse res) { // Yes reaching up this far is shit :( if (!HFTGameManager.GetInstance().HaveGame()) { res.ContentType = "application/json"; res.StatusCode = (int)HttpStatusCode.BadRequest; res.WriteContent(System.Text.Encoding.UTF8.GetBytes("{\"error\":\"game not ready:\"}")); } else { m_webServerUtils.SendJsonBytes(res, m_ping); } }
public HFTPlayer(HFTSocket client, HFTGameManager server, string id) { client_ = client; gameManager_ = server; id_ = id; log_ = new HFTLog("HFTPlayer[" + id + "]"); log_.Info("start player"); client.OnMessageEvent += HandleMessage; client.OnCloseEvent += HandleDisconnect; RegisterCmdHandler <AddPlayerToGameMessage>("join", AddPlayerToGame); RegisterCmdHandler <HFTRuntimeOptions>("server", AssignAsServerForGame); RegisterCmdHandler <object>("update", PassMessageFromPlayerToGame); }
public void StopListening() { // It's not clear to me where this belongs. Ideally I'd like to pass in the HFTGameManager // but how to pass it to new connections I have no idea. HFTGameManager.GetInstance().Close(); }