Beispiel #1
0
 /**
  * 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;
 }
 /**
  * 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;
        }
Beispiel #4
0
        static public HFTGameManager GetInstance()
        {
            if (s_instance == null)
            {
                s_instance = new HFTGameManager();
            }

            return(s_instance);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 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);
     }
 }
Beispiel #8
0
        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);
        }
Beispiel #9
0
 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();
 }