AddEvent() public static méthode

public static AddEvent ( int _event, ByteBuffer data ) : void
_event int
data ByteBuffer
Résultat void
 private void Update()
 {
     if (NetworkManager.mEvents.Count > 0)
     {
         while (NetworkManager.mEvents.Count > 0)
         {
             KeyValuePair <int, ByteBuffer> keyValuePair = NetworkManager.mEvents.Dequeue();
             base.facade.SendMessageCommand("DispatchMessage", keyValuePair);
         }
     }
     if (this.lostConnect && !this.inReconnect)
     {
         this.reconnectTime -= Time.deltaTime;
         if (this.reconnectTime <= 0f)
         {
             if (this.SocketClient != null)
             {
                 this.SocketClient.Close();
             }
             NetworkManager.AddEvent(107, new ByteBuffer());
             this.reconnectTime = 3f;
             this.inReconnect   = true;
             this.SendConnect();
             Debug.LogWarning("reconnecting to the server...");
         }
     }
 }
Exemple #2
0
        private bool HandlePush_Ex(PhobosPacket packet)
        {
            //1.二进制传输的消息 直接广播出去
            var bytecmd = packet.Command.GetType() == typeof(ByteNetCommand);

            if (bytecmd)
            {
                NetworkManager.AddEvent(Protocal.Message, (ByteNetCommand)packet.Command);
                return(true);
            }

            var pid = Registry.MustFind(packet.Command.GetType());

            //2. 服务器下推消息
            NetCallback callback = null;

            if (mHandlers.TryGetValue(pid, out callback))
            {
                // 调用回调函数
                callback.Invoke(packet.Head, packet.Command);
                return(true);
            }

            Util.Log($"Push callback not found for: {pid}");
            return(false);
        }
Exemple #3
0
        IEnumerator BeginReconnect()
        {
            yield return(Yielders.GetWaitForSeconds(1));

            NetworkManager.AddEvent(Protocal.BeginReconnect, new ByteBuffer());
            SendConnect();
            Debug.LogWarning("reconnecting to the server...");
        }
Exemple #4
0
 static int AddEvent(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         LuaFramework.NetworkManager obj = (LuaFramework.NetworkManager)ToLua.CheckObject(L, 1, typeof(LuaFramework.NetworkManager));
         int         arg0 = (int)LuaDLL.luaL_checknumber(L, 2);
         LuaFunction arg1 = ToLua.CheckLuaFunction(L, 3);
         object[]    arg2 = ToLua.CheckObjectArray(L, 4);
         obj.AddEvent(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #5
0
        /// <summary>
        /// 创建一个网络
        /// </summary>
        public CitrusNetWork CreateNetWork(Dictionary <uint, Type> protos = null)
        {
            CitrusNetWork mNetwork = new CitrusNetWork();

            mNetwork.OnConnHeartbeat = () => {
                //心跳包
                mNetwork.SendMessage(new logic.proto.CS_Player_Tick {
                    msg = "test"
                }, (cmd) => {
                    NetworkManager.AddEvent(Protocal.Message, (ByteNetCommand)cmd);
                });
            };
            mNetwork.RegisterProtos(protos);
            netWorkList.Add(mNetwork);

            return(mNetwork);
        }