示例#1
0
        protected virtual void Updated()  //TODO xx
        {
            if (toReconnect)              //连接成功
            {
                toReconnect = false;
                queue_LogError.Enqueue(Enum_NetEvent.WifiOff.ToString());
            }


            while (queue_cmd.Count > 0)              //此处必需在主线程中运行,否则报错 e.g.:: get_realtimeSinceStartup can only be called from the main thread.
            {
                DebugTool.LogYellow("[TCP] [rcv] | queue_cmd.Count : " + queue_cmd.Count);
                short cmd = queue_cmd.Dequeue();
                DebugTool.LogYellow("[TCP] [rcv] cmd:::::::::: " + cmd + " | queue_cmd.Count remain : " + queue_cmd.Count);
                queue_LogError.Enqueue("[TCP] [rcv] cmd:::::::::: " + cmd + " | queue_cmd.Count remain : " + queue_cmd.Count);
                CreateMessage(cmd);                  // cmd short -> int
            }

            //
            if (queue_LogError.Count > 0)
            {
                string log = queue_LogError.Dequeue();
                // DebugTool.Log (">>>>>>>>>> " + log); xxx 暂时去掉,以便调试UDP
                if (log == Enum_NetEvent.WifiOff.ToString())
                {
                    TimerMgr.HeartBeatStop();
                    Facade_Base.instance.DispatchEvent(new CEvent(Enum_NetEvent.WifiOff.ToString(), null)); // 显示出WIFI标识
                    Socket_Create_Connection();                                                             //重新创建连接
                }
                else if (log == Enum_NetEvent.WifiOn.ToString())
                {
                    //					    TimerMgr.HeartBeatStart ();
                    Facade_Base.instance.DispatchEvent(new CEvent(Enum_NetEvent.WifiOn.ToString(), null));
                }
                else if (log == Enum_Base.SocketClosed.ToString())
                {
                    LoginInfo.LoginState = false;
                    Facade_Base.instance.DispatchEvent(new CEvent(Enum_Base.SocketClosed.ToString(), null));
                }
            }
        }