public bool SendWithSerial(uint cmdId
                                   , IExtensible message
                                   , NetworkMessageHandle callback
                                   , bool displayTip = false
                                   , TimerEntity.TimerEntityCallBack timeoutCallback = null
                                   , double timeout = 10
                                   , int connID     = -1
                                   , uint serial    = 0
                                   , string tag     = "None")
        {
            bool result = proxy.Write(cmdId, message, serial, connID);

            if (!result)
            {
                ///发送失败直接超时回调
                if (timeoutCallback != null)
                {
                    DelayTimeoutCallbackData timeoutData = new DelayTimeoutCallbackData(timeoutCallback, serial);
                    NetworkManager.timeoutCallbackDataList.Add(timeoutData);
                    router.OnTimeoutConnectCheck();
                }
            }
            else
            {
                router.AddUnicastCallback(cmdId, serial, callback
                                          , displayTip, timeoutCallback, timeout
                                          , connID, tag, PBTYPE.CSharpPB);
            }

            return(result);
        }
        public bool SendMessage(uint cmdId
                                , IExtensible message
                                , NetworkMessageHandle callback
                                , bool displayTip = false
                                , TimerEntity.TimerEntityCallBack timeoutCallback = null
                                , double timeout = 10
                                , int connID     = -1
                                , string tag     = "None")
        {
            uint serial = router.NextSerial(cmdId, tag);
            bool result = true;

            // Update by Chicheng
            MessageManager msgManager = MessageManager.Instance;

            // 模拟服务器,从本地读包
            if (msgManager.IsActivate && !msgManager.IsSerializeToLocal)
            {
                // 反序列化之后的结果
                List <object> messagesBody = msgManager.deserializeFromLocal(cmdId);
                try
                {
                    __Proxy.__QueueAddMessage(cmdId, serial, messagesBody);
                }
                catch (NullReferenceException)
                {
                    return(false);
                }
            }
            else
            {
                result = proxy.Write(cmdId, message, serial, connID);
            }

            if (!result)
            {
                ///发送失败直接超时回调
                if (timeoutCallback != null)
                {
                    DelayTimeoutCallbackData timeoutData = new DelayTimeoutCallbackData(timeoutCallback, serial);
                    NetworkManager.timeoutCallbackDataList.Add(timeoutData);
                    router.OnTimeoutConnectCheck();
                }
            }
            else
            {
                router.AddUnicastCallback(cmdId, serial, callback
                                          , displayTip, timeoutCallback, timeout
                                          , connID, tag, PBTYPE.CSharpPB);
            }

            return(result);
        }
        static public void FixUpdate()
        {
            _fix_udpate = true;

            if (_net_work_proxy != null)
            {
                _net_work_proxy.Update();
            }

            for (int i = 0; i < NetworkManager.timeoutCallbackDataList.Count; i++)
            {
                DelayTimeoutCallbackData timeoutData = NetworkManager.timeoutCallbackDataList[i];
                timeoutData.timeoutCallback(timeoutData.serial);
            }

            NetworkManager.timeoutCallbackDataList.Clear();
        }
        /// <summary>
        /// 共Lua使用的非泛型方法
        /// 返回值为 0 说明是发送失败,否则返回 serial
        /// </summary>
        public SendUnicastRetInfo SendUnicast(uint cmdId,
                                              object message,
                                              NetworkMessageHandle callback,
                                              bool displayTip = false,
                                              TimerEntity.TimerEntityCallBack timeoutCallback = null,
                                              double timeout = 10,
                                              int connID     = -1,
                                              string tag     = "None")
        {
            uint serial = router.NextSerial(cmdId, tag);
            bool result = true;

            // Update by Chicheng
            MessageManager msgManager = MessageManager.Instance;

            // 模拟服务器,从本地读包
            if (msgManager.IsActivate && !msgManager.IsSerializeToLocal)
            {
                // Debug.LogWarning("模拟服务器,从本地读包Lua");
                // Lua反序列化之后的结果
                try
                {
                    List <object> messagesBody = msgManager.deserializeFromLocal(cmdId);
                    if (messagesBody != null)
                    {
                        __Proxy.__QueueAddMessage(cmdId, serial, messagesBody);
                        //__Proxy.AddMessage(cmdId, serial, messagesBody[0]);
                    }
                }
                catch (Exception)
                {
                    Debug.LogWarning("Lua这里出错");
                }
            }
            else
            {
                result = proxy.Write(cmdId, message, serial, connID);
            }



            if (result)
            {
                PBTYPE pbtype = PBTYPE.None;
                if (message is byte[])
                {
                    pbtype = PBTYPE.LuaPB;
                }
                else
                {
                    pbtype = PBTYPE.CSharpPB;
                }

                router.AddUnicastCallback(cmdId, serial, callback
                                          , displayTip
                                          , timeoutCallback
                                          , timeout
                                          , connID
                                          , tag
                                          , pbtype);

                m_retInfo.SetData(true, serial);
            }
            else
            {
                if (timeoutCallback != null)
                {
                    DelayTimeoutCallbackData timeoutData = new DelayTimeoutCallbackData(timeoutCallback, serial);
                    NetworkManager.timeoutCallbackDataList.Add(timeoutData);
                    router.OnTimeoutConnectCheck();
                }

                m_retInfo.SetData(false, serial);
            }

            return(m_retInfo);
        }