Exemple #1
0
 public static HFTGlobalEventEmitter GetInstance()
 {
     if (s_instance == null)
     {
         s_instance = new HFTGlobalEventEmitter();
     }
     return(s_instance);
 }
Exemple #2
0
        /// <summary>
        /// Constructor for GameServer
        /// </summary>
        /// <param name="options">The objects</param>
        /// <param name="gameObject">gameObject that will process messages from HappyFunTimes</param>
        public GameServer(HFTRuntimeOptions options, GameObject gameObject)
        {
            m_options      = options;
            HFTLog.debug   = options.debug;
            m_gameObject   = gameObject;
            m_players      = new Dictionary <string, NetPlayer>();
            m_sendQueue    = new List <String>();
            m_deserializer = new Deserializer();
            m_handlers     = new Dictionary <string, CmdEventHandler>();

            m_eventProcessor = m_gameObject.AddComponent <HFTEventProcessor>();
            HFTGlobalEventEmitter.GetInstance().Setup(m_eventProcessor);

            m_msgHandlers.Add("update", UpdatePlayer);
            m_msgHandlers.Add("upgame", UpdateGame);
            m_msgHandlers.Add("start", StartPlayer);
            m_msgHandlers.Add("gamestart", StartGame);
            m_msgHandlers.Add("remove", RemovePlayer);
            m_msgHandlers.Add("system", DoSysCommand);
            m_msgHandlers.Add("log", LogMessage);
        }
        public void DoWork()
        {
            try
            {
                log_.Info("DNS DoWork -start- port:" + port_);
                dnsServer_ = new HFTDnsServer(ipv4Address_, ipv6Address_);
                dnsServer_.Listen(port_);
                log_.Info("DNS DoWork -end-");
            }
            catch (System.Exception ex)
            {
                string msg =
                    "Could not start DNS Server on port:" + port_ + "\n" +
                    "Did you run from the command line with sudo?\n\n" + ex.ToString();

                if (!HFTGlobalEventEmitter.GetInstance().QueueEvent(HFTGlobalEventType.Error, msg))
                {
                    // No one handled it. Let's do it ourselves.
                    eventProcessor_.QueueEvent(() => {
                        HFTDialog.MessageBox("ERROR", msg);
                    });
                }
            }
        }
 public static HFTGlobalEventEmitter GetInstance()
 {
     if (s_instance == null)
     {
         s_instance = new HFTGlobalEventEmitter();
     }
     return s_instance;
 }