Esempio n. 1
0
        void Update()
        {
            if (_receiver != null)
            {
                _receiver.Update();
                _receiver.PeakQueue(msgCache);
                while (msgCache.Count > 0)
                {
                    var msg = msgCache.Dequeue();

                    //                    Debug.Log(msg.moduleId+":"+msg.subId);
                    NetMsgListener d = NetMsgListenerMgr.Instance.GetListener(msg.moduleId, msg.subId);
                    if (d != null)
                    {
                        //                        try
                        {
                            d(msg);
                        }
                        //                        catch (Exception e)
                        //                        {
                        //                            Debug.LogError(e.Message+e.StackTrace);
                        //                        }
                    }
                }
            }
            if (_sender != null)
            {
                _sender.Update();
            }
        }
Esempio n. 2
0
        public void SendBuyOrSellReq(int ShoppingItemID, int Count, int buyOrSell)
        {
            if (FieldsController.ProtocalAction != ProtocalAction.None)
            {
                return;
            }
            else
            {
                FieldsController.ProtocalAction = ProtocalAction.Buy;
            }

            var builder = Farm_Game_buyOrSell_Req.CreateBuilder();

            builder.UserGameID     = LoginModel.Instance.Uid;
            builder.ShoppingItemID = ShoppingItemID;
            builder.Count          = Count;
            builder.BuyOrSell      = buyOrSell;

            NetMsgListener _listener = NetMsgListenerMgr.Instance.GetListener(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req);

            NetMsgListenerMgr.Instance.UnRegisterMsgListener(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req, _listener);
            _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_buyOrSell_Req, AnwBuyOrSellCallBack);

            _Proxy.SendMsg(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req, builder);

            GetDispatcher().Dispatch(ShopEvent.OnBuying, Count);
        }
Esempio n. 3
0
        public void RegisterMsgListener(byte module, byte sub, NetMsgListener listener)
        {
            var list = GetFunList(module, sub);

            if (list[sub] != null && list[sub] != listener)
            {
                UnityEngine.Debug.LogError(string.Format("NetMessageListener Duplicat error: old:{0},new:{1}", list[sub].Method.Name, listener.Method.Name));
            }
            list[sub] = listener;
        }
Esempio n. 4
0
        //仓库卖出请求
        public void SellItem(int UserGameID, int ShoppingItemID, int Count, int buyOrSell)
        {
            if (FieldsController.ProtocalAction != ProtocalAction.None)
            {
                return;
            }
            else
            {
                FieldsController.ProtocalAction = ProtocalAction.Sell;
            }

            Farm_Game_buyOrSell_Req.Builder builder = Farm_Game_buyOrSell_Req.CreateBuilder();
            builder.UserGameID     = UserGameID;
            builder.ShoppingItemID = ShoppingItemID;
            builder.Count          = Count;
            builder.BuyOrSell      = 1;

            NetMsgListener _listener = NetMsgListenerMgr.Instance.GetListener(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req);

            NetMsgListenerMgr.Instance.UnRegisterMsgListener(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req, _listener);
            _Proxy.AddNetListenner(NetModules.GameAction.Farm_Game_buyOrSell_Req, StoreSellCallBack);

            _Proxy.SendMsg(NetModules.GameAction.ModuleId, NetModules.GameAction.Farm_Game_buyOrSell_Req, builder);
        }
Esempio n. 5
0
 public void AddNetListenner(byte sub, NetMsgListener responeListener)
 {
     NetMsgListenerMgr.Instance.RegisterMsgListener(_module, sub, responeListener);
 }
Esempio n. 6
0
        public void UnRegisterMsgListener(byte module, byte sub, NetMsgListener listener)
        {
            var list = GetFunList(module, sub);

            list[sub] = null;
        }