Example #1
0
 private static void SendMessage(NetServer server, MsgBase msg)
 {
     NetOutgoingMessage om = server.CreateMessage();
     om.Write(msg.Id);
     msg.W(om);
     server.SendToAll(om, NetDeliveryMethod.Unreliable);
 }
Example #2
0
 private static void SendMessage(NetServer server, MsgBase msg, NetConnection conn)
 {
     NetOutgoingMessage om = server.CreateMessage();
     om.Write(msg.Id);
     msg.W(om);
     server.SendMessage(om, conn, NetDeliveryMethod.Unreliable, 0);
 }
Example #3
0
 private void OnHappyPlayerLoginRsp(MsgBase b)
 {
     var rspMsg          = (Msg_HappyPlayerLoginRsp)b;
     Uid                 = rspMsg.Uid;
     var sid             = rspMsg.SpriteId;
     Player              = CozyTileSprite.Create(PlayerTextureMgr.Get(sid));
     Player.TilePosition = new Point(rspMsg.X, rspMsg.Y);
     this.AddChind(Player, 2);
 }
Example #4
0
 private void OnHappyOtherPlayerLogin(MsgBase b)
 {
     var otherMsg                    = (Msg_HappyOtherPlayerLogin)b;
     var sid                         = otherMsg.SpriteId;
     var sp                          = CozyTileSprite.Create(PlayerTextureMgr.Get(sid));
     sp.TilePosition                 = new Point(otherMsg.X, otherMsg.Y);
     OtherPlayerList[otherMsg.Uid]   = sp;
     this.AddChind(sp, 1);
 }
Example #5
0
 public void SendMessage(MsgBase msg)
 {
     lock (msgQueuelocker)
     {
         NetOutgoingMessage om = client.CreateMessage();
         om.Write(msg.Id);
         msg.W(om);
         msgQueue.Enqueue(new NetClientMsg(om, NetDeliveryMethod.Unreliable));
     }
 }
Example #6
0
 private void OnHappyPlayerQuit(MsgBase b)
 {
     var quitMsg = (Msg_HappyPlayerQuit)b;
     uint quid   = quitMsg.Uid;
     if (OtherPlayerList.ContainsKey(quid))
     {
         var player = OtherPlayerList[quid];
         player.StopAllActions();
         this.RemoveChild(player);
         OtherPlayerList.Remove(quid);
     }
 }
Example #7
0
 private void OnHappyPlayerMove(MsgBase b)
 {
     var moveMsg = (Msg_HappyPlayerMove)b;
     uint uid    = moveMsg.Uid;
     if (OtherPlayerList.ContainsKey(uid))
     {
         var player = OtherPlayerList[uid];
         if (player != null)
         {
             var dire = MoveDirectionToPointConverter.PointConvertToMoveDirection(new Point(moveMsg.X, moveMsg.Y));
             player.Move(dire);
         }
     }
 }
Example #8
0
 private void OnHappyPlayerPack(MsgBase b)
 {
     var packMsg = (Msg_HappyPlayerPack)b;
     foreach (var obj in packMsg.PlayerPack)
     {
         if (obj.Item4)
         {
             var sid                     = obj.Item5;
             var osp                     = CozyTileSprite.Create(PlayerTextureMgr.Get(sid));
             osp.TilePosition            = new Point(obj.Item2, obj.Item3);
             OtherPlayerList[obj.Item1]  = osp;
             this.AddChind(osp, 1);
         }
     }
 }
Example #9
0
        private static void SendMessageExceptOne(NetServer server,MsgBase msg, NetConnection except)
        {
            NetOutgoingMessage oom = server.CreateMessage();
            oom.Write(msg.Id);
            msg.W(oom);

            List<NetConnection> all = server.Connections;
            if(all.Contains(except))
            {
                all.Remove(except);
            }
            if (all.Count > 0)
            {
                server.SendMessage(oom, all, NetDeliveryMethod.Unreliable, 0);
            }
        }
Example #10
0
        private void OnLoginRsp(MsgBase b)
        {
            var selfMsg     = (Msg_AgarLoginRsp)b;
            Uid             = selfMsg.Uid;
            int X_Size      = selfMsg.Width;
            int Y_Size      = selfMsg.Height;
            MapSize         = new Point(X_Size, Y_Size);

            string RdName   = "TestName-" + RandomMaker.NextString(5);
            var bornMsg     = new Msg_AgarBorn();
            bornMsg.UserId  = Uid;
            bornMsg.Name    = RdName;
            Name            = RdName;

            client.SendMessage(bornMsg);
        }
Example #11
0
    public override void ProcessEvent(MsgBase msg)
    {
        base.ProcessEvent(msg);
        switch (msg.msgId)
        {
        case (ushort)Enum_UI.LoginSuccess:
            Debug.Log("LoginSuccess");
            break;

        case (ushort)Enum_UI.LoginFaild:
            Debug.Log("LoginFaild");
            break;

        default:
            break;
        }
    }
Example #12
0
    //收到退出房间协议
    public void OnMsgLeaveRoom(MsgBase msgBase)
    {
        MsgLeaveRoom msg = (MsgLeaveRoom)msgBase;

        //成功退出房间
        if (msg.result == 0)
        {
            //PanelManager.Open<TipPanel>("退出房间");
            PanelManager.Open <RoomListPanel>();
            Close();
        }
        //退出房间失败
        else
        {
            PanelManager.Open <TipPanel>("退出房间失败");
        }
    }
Example #13
0
    public override void ProcessEvent(MsgBase tmpMag)
    {
        switch (tmpMag.msgid)
        {
        case (ushort)UIEvent.ShowMySubcribe:
        {
            SubscribeRoot.gameObject.SetActive(true);
        }
        break;

        case (ushort)UIEvent.ShowLauncher:

        {
        }
        break;
        }
    }
Example #14
0
    public void DonePress()
    {
        Debug.Log("BtnPress");

        MsgBase tmpBase = ObjectPoolManager <MsgBase> .Instance.GetFreeObject();


        tmpBase.ChangeEventId((ushort)UIDemoLoading.ShowPanel);

        SendMsg(tmpBase);

        ObjectPoolManager <MsgBase> .Instance.ReleaseObject(tmpBase);



        gameObject.SetActive(false);
    }
Example #15
0
    //收到注册协议
    public void OnMsgRegister(MsgBase msgBase)
    {
        MsgRegister msg = (MsgRegister)msgBase;

        if (msg.result == 0)
        {
            Debug.Log("注册成功");
            //提示
            PanelManager.Open <TipPanel>("注册成功");
            //关闭界面
            Close();
        }
        else
        {
            PanelManager.Open <TipPanel>("注册失败");
        }
    }
Example #16
0
    //数据处理
    public static void OnReceiveData()
    {
        //消息长度
        if (readBuff.length <= 2)
        {
            return;
        }
        //获取消息体长度
        int readIdx = readBuff.readIdx;

        byte[] bytes      = readBuff.bytes;
        Int16  bodyLength = (Int16)((bytes[readIdx + 1] << 8) | bytes[readIdx]);

        if (readBuff.length < bodyLength)
        {
            return;
        }
        readBuff.readIdx += 2;
        //解析协议名
        int    nameCount = 0;
        string protoName = MsgBase.DecodeName(readBuff.bytes, readBuff.readIdx, out nameCount);

        if (protoName == "")
        {
            Debug.Log("OnReceiveData MsgBase.DecodeName fail");
            return;
        }
        readBuff.readIdx += nameCount;
        //解析协议体
        int     bodyCount = bodyLength - nameCount;
        MsgBase msgBase   = MsgBase.Decode(protoName, readBuff.bytes, readBuff.readIdx, bodyCount);

        readBuff.readIdx += bodyCount;
        readBuff.CheckAndMoveBytes();
        //添加到消息队列
        lock (msgList){
            msgList.Add(msgBase);
            msgCount++;
        }
        //继续读取消息
        if (readBuff.length > 2)
        {
            OnReceiveData();
        }
    }
Example #17
0
        /// <summary>
        /// Shows the Yes/No/Cancel dialog.
        /// </summary>
        /// <param name="owner">The owner.</param>
        /// <param name="message">The message.</param>
        /// <param name="title">The title.</param>
        /// <param name="defaultResult">The default result.</param>
        /// <returns></returns>
        public YesNoCancelDialogResult ShowYesNoCancel(IWin32Window owner, string title,
                                                       string message,
                                                       YesNoCancelDialogResult
                                                       defaultResult)
        {
            Assert.ArgumentNotNullOrEmpty(title, nameof(title));
            Assert.ArgumentNotNullOrEmpty(message, nameof(message));

            _msg.Info(message);

            string msg = MsgBase.ReplaceBreakTags(message);

            MessageBoxDefaultButton defaultButton;

            switch (defaultResult)
            {
            case YesNoCancelDialogResult.Yes:
                defaultButton = MessageBoxDefaultButton.Button1;
                break;

            case YesNoCancelDialogResult.No:
                defaultButton = MessageBoxDefaultButton.Button2;
                break;

            case YesNoCancelDialogResult.Cancel:
                defaultButton = MessageBoxDefaultButton.Button3;
                break;

            default:
                throw new ArgumentException(
                          string.Format(
                              "Invalid default result ({0})", defaultResult),
                          nameof(defaultResult));
            }

            DialogResult result = Show(owner, msg, title,
                                       MessageBoxButtons.YesNoCancel,
                                       MessageBoxIcon.Question,
                                       defaultButton);

            _msg.DebugFormat("YES NO CANCEL Dialog: {0}, '{1}'. Answer: '{2}'",
                             msg, title, result);

            return(GetYesNoCancelAnswer(result));
        }
Example #18
0
        private void OnPlayerInfo(MsgBase b)
        {
            var selfMsg     = (Msg_AgarPlayInfo)b;
            uint id         = selfMsg.UserId;
            if (selfMsg.Operat == Msg_AgarPlayInfo.Add)
            {
                var player = new DefaultUserCircle(
                    new Vector2(selfMsg.X, selfMsg.Y),
                    selfMsg.Radius,
                    selfMsg.Color,
                    selfMsg.Name);

                CircleList[id] = player;
                this.AddChind(player, OtherPlayerZOrder);
            }
            else if (selfMsg.Operat == Msg_AgarPlayInfo.Remove)
            {
                if (!CircleList.ContainsKey(id)) return;
                var player = CircleList[id];
                this.RemoveChild(player);
                CircleList.Remove(id);
            }
            else if (selfMsg.Operat == Msg_AgarPlayInfo.Changed)
            {
                if (!CircleList.ContainsKey(id)) return;
                uint tag    = selfMsg.Tag;
                var player  = CircleList[id];
                if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.POSITION_TAG))
                {
                    player.Position = new Vector2(selfMsg.X, selfMsg.Y);
                }
                if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.RADIUS_TAG))
                {
                    player.Radius = selfMsg.Radius;
                }
                if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.COLOR_TAG))
                {
                    player.ColorProperty = selfMsg.Color.ToColor();
                }
                if (GameMessageHelper.Is_Changed(tag, GameMessageHelper.NAME_TAG))
                {
                    player.Name = selfMsg.Name;
                }
            }
        }
Example #19
0
    void ButtonOnClick(Transform button)
    {
        // Debug.Log("fasfdaf");
        userCenterRoot.gameObject.SetActive(false);
        SendMsg(new MsgBase((ushort)UIEvent.HideBottomPart));
        switch (button.name)
        {
        case "AccountSettingButton":
            MsgBase msg = new MsgBase((ushort)UIEvent.ShowAccountSetting);
            SendMsg(msg);
            break;

        case "FavoriteButton":
            MsgBase msg1 = new MsgBase((ushort)UIEvent.ShowFavorite);
            SendMsg(msg1);
            break;

        case "HistoricalRecordButton":

            MsgBase msg2 = new MsgBase((ushort)UIEvent.ShowHistoricalRecord);
            SendMsg(msg2);
            break;

        case "CustomerServiceButton":
            CustomerService.gameObject.SetActive(true);
            userCenterRoot.gameObject.SetActive(false);


            break;

        case "MySubscriptionButton":
            Debug.Log("MySubscriptionButton");
            MsgBase msg3 = new MsgBase((ushort)UIEvent.ShowMySubcribe);
            SendMsg(msg3);

            break;

        case "AboultButton":
            SendMsg(new MsgBase((ushort)UIEvent.ShowAboult));
            break;

        default:
            break;
        }
    }
Example #20
0
        /// <summary>
        /// 处理应用内信息
        /// </summary>
        /// <param name="msg"></param>
        public override void ProcessEvent(MsgBase msg)
        {
            switch (msg.MsgId)
            {
            case (ushort)NetEventSelect.EnterRequest:
                Send(SelectProtocol.ENTER_CREQ);
                break;

            case (ushort)NetEventSelect.SelectRequest:
                MsgInt msgInt = msg as MsgInt;
                Send(SelectProtocol.SELECT_CREQ, msgInt.Int);
                break;

            case (ushort)NetEventSelect.ReadyRequest:
                Send(SelectProtocol.READY_CREQ);
                break;
            }
        }
Example #21
0
    //来了消息 通知整个消息链表
    public override void ProcessEvent(MsgBase tmpMsg)
    {
        if (!enventTree.ContainsKey(tmpMsg.msgId))
        {
            Debug.LogError("msg not contain msgid == " + tmpMsg.msgId);
            Debug.LogError("msg manager == " + tmpMsg.GetManager());
            return;
        }
        else
        {
            EventNode tmp = enventTree[tmpMsg.msgId];

            do
            {
                tmp.data.ProcessEvent(tmpMsg);
            }while (tmp != null);
        }
    }
Example #22
0
    public override void ProcessEvent(MsgBase tmpMag)
    {
        switch (tmpMag.msgid)
        {
        case (ushort)UIEvent.ShowBottomPart:
        {
            BottomButtonContent.gameObject.SetActive(true);
        }
        break;

        case (ushort)UIEvent.HideBottomPart:

        {
            BottomButtonContent.gameObject.SetActive(false);
        }
        break;
        }
    }
Example #23
0
        public virtual void ParseMsg(PackPeer packpeer, byte[] bytes)
        {
            MsgBase ma = new MsgBase();

            if (!ma.Deserialize(bytes))
            {
                AppModules.Instance.LogManager.Log.Error(string.Format("ParseMsg error {0}", packpeer.Get_RemoteEndPoint().ToString()));
                return;
            }
            try
            {
                EventMsgPool.FireEvent(ma.MsgHead.m_msgid, packpeer, ma);
            }
            catch (Exception e)
            {
                AppModules.Instance.LogManager.Log.Error(string.Format("MsgId:{0}--exception", ma.MsgHead.m_msgid, e.ToString()));
            }
        }
Example #24
0
    // 来了消息,通知整个消息链表
    public override void ProcessEvent(MsgBase msg)
    {
        if (!eventTree.ContainsKey(msg.msgID))
        {
            Debug.LogError("msg not contains msgID == " + msg.msgID);
            Debug.LogError("msg manager == " + msg.GetManagerID());
            return;
        }

        EventNode currentNode = eventTree[msg.msgID];

        do
        {
            currentNode.data.ProcessEvent(msg);

            currentNode = currentNode.next;
        } while (currentNode != null);
    }
Example #25
0
    public override void ProcessEvent(MsgBase tmpMsg)
    {
        switch (tmpMsg.msgId)
        {
        case (ushort)TabToyEvent.TableCharactorGet:
        {
            TableCharactorMsg tmp             = (TableCharactorMsg)tmpMsg;
            CharactorDefine   tmpsampleDefine = GetCharactorDefine(tmp.id);
            tmp.msgId           = (ushort)TabToyEvent.TableCharactorBack;
            tmp.charactorDefine = tmpsampleDefine;
            SendMsg(tmp);
        }
        break;

        default:
            break;
        }
    }
    public void OnMsgQuit(MsgBase msgBase)
    {
        MsgQuit msg = (MsgQuit)msgBase;

        useQuitButton = msg.isQuit;
        if (msg.isQuit)
        {
            NetManager.Close();
            Application.Quit();
        }
        else
        {
            PanelManager.Open <TipPanel>("有人退出,游戏被迫中止!");
            PanelManager.Open <GameoverPanel>(-1, client_id, msg.id);
            PanelManager.Close("GamePanel");
            //直接平局
        }
    }
Example #27
0
 /// <summary>
 /// 注册协议
 /// </summary>
 /// <param name="protocol"></param>
 /// <param name="receiver"></param>
 public void Register(MsgBase tmpMsg, Action <MsgBase> handler)
 {
     if (eventTree.ContainsKey(tmpMsg.msgId))
     {
         if (eventTree[tmpMsg.msgId] == null)
         {
             eventTree[tmpMsg.msgId] = handler;
         }
         else
         {
             eventTree[tmpMsg.msgId] += handler;
         }
     }
     else
     {
         eventTree.Add(tmpMsg.msgId, handler);
     }
 }
        public void HandleVotes(MsgBase msg)
        {
            VotesDetails vote = msg as VotesDetails;

            if (!m_Votes.ContainsKey(vote.State))
            {
                m_Votes.Add(vote.State, new Dictionary <string, VotesDetails>());
            }

            if (!m_Votes[vote.State].ContainsKey(vote.CandidateId))
            {
                m_Votes[vote.State].Add(vote.CandidateId, vote);
            }
            else
            {
                m_Votes[vote.State][vote.CandidateId] = vote;
            }
        }
Example #29
0
    public override void ProcessEvent(MsgBase msg)
    {
        switch (msg.msgId)
        {
        case (ushort)TestUIAEvent.Initial:
        {
            TestUIAMsg tmpMsg = (TestUIAMsg)msg;



            Debug.Log("A  evnet  coming!!" + tmpMsg.ower.name);
        }
        break;

        default:
            break;
        }
    }
Example #30
0
    public override void ProcessEvent(MsgBase tmpMag)
    {
        switch (tmpMag.msgid)
        {
        case (ushort)UIEvent.ShowHistoricalRecord:
        {
            HistorialRoot.gameObject.SetActive(true);
        }
        break;

        case (ushort)UIEvent.HideHistoryRecord:

        {
            HistorialRoot.gameObject.SetActive(false);
        }
        break;
        }
    }
Example #31
0
    public override void ProcessEvent(MsgBase msg)
    {
        switch (msg.msgId)
        {
        case (ushort)UIPanel_Zhou.Initial:
            break;

        case (ushort)UIPanel_Zhou.ChangeName:
            break;


        case (ushort)UIPanel_Zhou.ButtonClick:
            break;

        default:
            break;
        }
    }
Example #32
0
        private static void SendMessageExceptOne(NetServer server, MsgBase msg, NetConnection except)
        {
            NetOutgoingMessage oom = server.CreateMessage();

            oom.Write(msg.Id);
            msg.W(oom);

            List <NetConnection> all = server.Connections;

            if (all.Contains(except))
            {
                all.Remove(except);
            }
            if (all.Count > 0)
            {
                server.SendMessage(oom, all, NetDeliveryMethod.Unreliable, 0);
            }
        }
Example #33
0
    // 编码协议名(2字节长度+协议名字符串)
    public static byte[] EncodeName(MsgBase msgBase)
    {
        // 名字bytes和长度
        byte[] nameBytes = System.Text.Encoding.UTF8.GetBytes(msgBase.protoName);
        Int16  len       = (Int16)nameBytes.Length;

        // 申请bytes数组
        byte[] bytes = new byte[2 + len];

        // 组装2字节的长度信息
        bytes[0] = (byte)(len % 256);
        bytes[1] = (byte)(len / 256);

        // 组装协议名
        Array.Copy(nameBytes, 0, bytes, 2, len);

        return(bytes);
    }
Example #34
0
        /// <summary>
        /// 处理应用内消息
        /// </summary>
        /// <param name="msg"></param>
        public override void ProcessEvent(MsgBase msg)
        {
            switch (msg.MsgId)
            {
            case (ushort)NetEventUser.CreateUser:
                MsgString msgString = msg as MsgString;
                Send(Protocol.Protocol.TYPE_USER, 0, UserProtocol.CREATE_CREQ, msgString.Str);
                break;

            case (ushort)NetEventUser.RequestUserInfo:
                Send(Protocol.Protocol.TYPE_USER, 0, UserProtocol.INFO_CREQ, null);
                break;

            case (ushort)NetEventUser.RequestOnline:
                Send(Protocol.Protocol.TYPE_USER, 0, UserProtocol.ONLINE_CREQ, null);
                break;
            }
        }
Example #35
0
        private static void OnStartBattle(MsgBase msgBase)
        {
            MsgStartBattle msg = (MsgStartBattle)msgBase;

            if (msg.code == HttpStatusCode.OK)
            {
                GameSence gameSence = ContainerBuilder.Resolve <GameSence>();

                List <MsgStartBattle.StartPlay> startPlays = msg.startPlays;
                foreach (var item in startPlays)
                {
                    Player player = new Player(item.Id, 100, 50, item.X, item.Y, 'x', SwichColor(item.Index));
                    gameSence.AddSprite(player);
                }
                gameSence.Load();
                ScenceController.curScence = gameSence;
            }
        }
Example #36
0
    public override void ProcessEvent(MsgBase tmpMsg)
    {
        switch (tmpMsg.msgId)
        {
        case (ushort)NpcEvent.WalkFront:
            //animator.SetTrigger ("");
            Debug.Log("animator walk front");
            break;

        case (ushort)NpcEvent.WalkBack:
            //animator.SetTrigger ("");
            Debug.Log("animator walk back");
            break;

        default:
            break;
        }
    }
Example #37
0
        //请求房间列表
        public static void MsgListRoom(ClientState c, MsgBase msgBase)
        {
            MsgListRoom msg  = (MsgListRoom)msgBase;
            User        user = c.user;

            if (user == null)
            {
                msg.code   = HttpStatusCode.Unauthorized;
                msg.result = "请先登录";
                NetManager.Send(c, msg);
            }
            else
            {
                msg.code   = HttpStatusCode.OK;
                msg.result = JsonConvert.SerializeObject(RoomManager.rooms);
                NetManager.Send(c, msg);
            }
        }
Example #38
0
 public override void ProcessEvent(MsgBase tmpMsg)
 {
     if (callBack != null)
     {
         //从网络来
         if (tmpMsg.GetState() != 127)
         {
             NetMsgBase    tmpBase = (NetMsgBase)tmpMsg;
             byte[]        proto   = tmpBase.GetProtoBuffer();
             LuaByteBuffer buffer  = new LuaByteBuffer(proto);
             callBack.Call(true, tmpBase.msgId, tmpBase.GetState(), buffer);
         }
         else  //从框架其他模块来的
         {
             callBack.Call(false, tmpMsg);
         }
     }
 }
Example #39
0
    /// <summary>
    /// 处理释放资源
    /// </summary>
    /// <param name="msg"></param>
    public override void HandleMsgEvent(MsgBase msg)
    {
        AssetMsg tmpMsg = (AssetMsg)msg;

        switch (tmpMsg.MsgID)
        {
        case (ushort)AssetEventMsg.ReleseAsset:
            Debug.Log("ReleseAsset name =" + tmpMsg.ResName);
            ABLoadManager.Instance.ReleseAsset(tmpMsg.ScenceName, tmpMsg.BundleName, tmpMsg.ResName);
            break;

        case (ushort)AssetEventMsg.ReleseBundleAsset:
            ABLoadManager.Instance.ReleseBundleAsset(tmpMsg.ScenceName, tmpMsg.BundleName);
            break;

        case (ushort)AssetEventMsg.ReleseScenceAllBundleAsset:
            ABLoadManager.Instance.ReleseScenceAllBundleAsset(tmpMsg.ScenceName);
            break;

        case (ushort)AssetEventMsg.ReleseAppBundleAsset:
            ABLoadManager.Instance.ReleseAppBundleAsset();
            break;

        case (ushort)AssetEventMsg.ReleseBundle:
            ABLoadManager.Instance.ReleseBundle(tmpMsg.ScenceName, tmpMsg.BundleName, false);
            break;

        case (ushort)AssetEventMsg.ReleseBundleAndAsset:
            ABLoadManager.Instance.ReleseBundle(tmpMsg.ScenceName, tmpMsg.BundleName, true);
            break;

        case (ushort)AssetEventMsg.ReleseScenceAllBundle:
            ABLoadManager.Instance.ReleseScenceAllBundle(tmpMsg.ScenceName);
            break;

        case (ushort)AssetEventMsg.ReleseAppBundle:
            ABLoadManager.Instance.ReleseAppBundle();
            break;

        case (ushort)AssetEventMsg.LoadAsset:
            LoadAsset(tmpMsg.ScenceName, tmpMsg.BundleName, tmpMsg.ResName, tmpMsg.IsSingle, tmpMsg.BackMsgId);
            break;
        }
    }
Example #40
0
    private static void OnReceiveData()
    {
        if (readBuff.length <= 2)
        {
            return;
        }
        // header
        int readIdx = readBuff.readIdx;

        byte[] bytes      = readBuff.bytes;
        Int16  bodyLength = (Int16)((bytes[readIdx + 1] << 8) | bytes[readIdx]);

        if (readBuff.length < bodyLength)
        {
            return;
        }
        readBuff.readIdx += 2;
        // name
        int    nameCount = 0;
        string protoName = MsgBase.DecodeName(readBuff.bytes, readBuff.readIdx, out nameCount);

        if (protoName == "")
        {
            UnityEngine.Debug.Log("OnReceiveData msgBase.Decodename fail");
            return;
        }
        readBuff.readIdx += nameCount;
        //body
        int     bodyCount = bodyLength - nameCount;
        MsgBase msgBase   = MsgBase.Decode <MsgBase>(protoName, readBuff.bytes, readBuff.readIdx, bodyCount);

        readBuff.readIdx += bodyCount;
        readBuff.CheckAndMoveBytes();
        //add list
        lock (msgList)
        {
            msgList.Add(msgBase);
        }
        msgCount++;
        if (readBuff.length > 2)
        {
            OnReceiveData();
        }
    }
Example #41
0
        private void OnSelf(MsgBase b)
        {
            var selfMsg = (Msg_AgarSelf)b;

            if (selfMsg.Operat == Msg_AgarSelf.Born)
            {
                float x = selfMsg.X;
                float y = selfMsg.Y;
                int   r = selfMsg.Radius;
                uint  c = selfMsg.Color;

                DefaultRadius = r;
                Player        = new DefaultUserCircle(new Vector2(x, y), r, c, Name);

                this.AddChind(Player, PlayerZOrder);

                if (ScoreShow != null)
                {
                    ScoreShow.Text = String.Format("Score : {0}", Player.Radius - DefaultRadius);
                }
            }
            else if (selfMsg.Operat == Msg_AgarSelf.GroupUp)
            {
                Player.Radius = selfMsg.Radius;
                if (ScoreShow != null)
                {
                    ScoreShow.Text = String.Format("Score : {0}", Player.Radius - DefaultRadius);
                }
            }
            else if (selfMsg.Operat == Msg_AgarSelf.Dead)
            {
                this.RemoveChild(Player);
                Player = null;

                // 玩家重生
                string RdName  = "TestName-" + RandomMaker.NextString(5);
                var    bornMsg = new Msg_AgarBorn();
                bornMsg.UserId = Uid;
                bornMsg.Name   = RdName;
                Name           = RdName;

                client.SendMessage(bornMsg);
            }
        }
Example #42
0
        private void OnFixedBall(MsgBase b)
        {
            var selfMsg     = (Msg_AgarFixedBall)b;
            uint id         = selfMsg.BallId;
            if (selfMsg.Operat == Msg_AgarFixedBall.Add)
            {
                var food    = new DefaultFoodCircle(
                    new Vector2(selfMsg.X, selfMsg.Y),
                    selfMsg.Radius, selfMsg.Color);

                FoodList[id] = food;
                this.AddChind(food, FoodZOrder);
            }
            else if (selfMsg.Operat == Msg_AgarFixedBall.Remove)
            {
                CozyCircle food = FoodList[id];
                this.RemoveChild(food);
                FoodList.Remove(id);
            }
        }
Example #43
0
File: Msg.cs Project: rsdn/janus
		private static List<MsgBase> GetOldStyleTopicList(
			IServiceProvider provider,
			int forumId,
			SortType sort,
			bool loadAll,
			MsgBase parent)
		{
			using (var db = provider.CreateDBContext())
			{
				var displayConfig = Config.Instance.ForumDisplayConfig;
				var q =
					AppendSortPredicate(db.TopicInfos(ti => ti.ForumID == forumId), sort);
				if (displayConfig.ShowUnreadThreadsOnly)
					q = q.Where(ti => !ti.Message.IsRead || ti.AnswersUnread > 0);
				if (!(loadAll || displayConfig.MaxTopicsPerForum <= 0))
					q = q.Take(displayConfig.MaxTopicsPerForum);

				var msgs =
					q
						.Select(
							ti =>
								new Msg(provider)
								{
									Parent = parent,
									IsChild = false,

									ID = ti.MessageID,
									ParentID = 0,
									ForumID = ti.ForumID,
									Name = ti.Message.Name,
									Date = ti.Message.Date,
									Subject = ti.Message.Subject,
									UserID = ti.Message.UserID,
									UserClass = (short)ti.Message.UserClass,
									UserNick = ti.Message.UserNick,
									IsRead = ti.Message.IsRead,
									IsMarked = ti.Message.IsMarked,
									Closed = ti.Message.Closed,
									ReadReplies = ti.Message.ReadReplies,
									LastModerated = ti.Message.LastModerated,
									ArticleId = ti.Message.ArticleId,
									Rating = ti.SelfRates,
									Smiles = ti.SelfSmiles,
									Agrees = ti.SelfAgrees,
									Disagrees = ti.SelfDisagrees,
									Moderatorials = ti.SelfModeratorials,
									RepliesCount = ti.AnswersCount,
									RepliesUnread = ti.AnswersUnread,
									RepliesRate = ti.AnswersRates,
									RepliesSmiles = ti.AnswersSmiles,
									RepliesAgree = ti.AnswersAgrees,
									RepliesDisagree = ti.AnswersDisagrees,
									RepliesToMeUnread = ti.AnswersToMeUnread,
									RepliesMarked = ti.AnswersMarked,
									RepliesModeratorials = ti.AnswersModeratorials
								})
						.Cast<MsgBase>()
						.ToList();
				foreach (var msg in msgs)
					msg.EndMapping();
				return msgs;
			}
		}
Example #44
0
		private void SetMessageMarked(MsgBase msg)
		{
			if (msg == null)
				return;
			_markTimer.Enabled = false;
			msg.SetMessageMarked(!msg.Marked);
			_tgMsgs.Update();
		}
Example #45
0
        private void OnMarkListPack(MsgBase b)
        {
            var selfMsg = (Msg_AgarMarkListPack)b;
            MarkList.Clear();

            foreach (var obj in selfMsg.MarkList)
            {
                if (CircleList.ContainsKey(obj.Key))
                {
                    MarkList.Add(new KeyValuePair<string, int>(CircleList[obj.Key].Name, obj.Value));
                }
                else if (obj.Key == Uid && Player != null)
                {
                    MarkList.Add(new KeyValuePair<string, int>(Player.Name, obj.Value));
                }
            }
            // 暂时只接受数据不显示
        }
Example #46
0
 public DataMessageArgs(MsgBase msg)
 {
     Msg = msg;
 }
Example #47
0
 private void OnFixBallPack(MsgBase b)
 {
     var selfMsg = (Msg_AgarFixBallPack)b;
     foreach (var obj in selfMsg.FixedList)
     {
         uint fid = obj.Item1;
         var food = new DefaultFoodCircle(new Vector2(obj.Item2, obj.Item3), obj.Item4, obj.Item5);
         FoodList[fid] = food;
         this.AddChind(food, FoodZOrder);
     }
 }
Example #48
0
        private void OnPlayInfoPack(MsgBase b)
        {
            var selfMsg = (Msg_AgarPlayInfoPack)b;
            foreach (var obj in selfMsg.PLayerList)
            {
                uint pid = obj.Item1;
                var player = new DefaultUserCircle(
                    new Vector2(obj.Item2, obj.Item3),
                    obj.Item4,
                    obj.Item5,
                    obj.Item6);

                CircleList[pid] = player;
                this.AddChind(player, OtherPlayerZOrder);
            }
        }
Example #49
0
        private void OnSelf(MsgBase b)
        {
            var selfMsg = (Msg_AgarSelf)b;

            if (selfMsg.Operat == Msg_AgarSelf.Born)
            {
                float x = selfMsg.X;
                float y = selfMsg.Y;
                int r   = selfMsg.Radius;
                uint c  = selfMsg.Color;

                DefaultRadius = r;
                Player = new DefaultUserCircle(new Vector2(x, y), r, c, Name);

                this.AddChind(Player, PlayerZOrder);

                if (ScoreShow != null)
                    ScoreShow.Text = String.Format("Score : {0}", Player.Radius - DefaultRadius);
            }
            else if (selfMsg.Operat == Msg_AgarSelf.GroupUp)
            {
                Player.Radius = selfMsg.Radius;
                if (ScoreShow != null)
                    ScoreShow.Text = String.Format("Score : {0}", Player.Radius - DefaultRadius);
            }
            else if (selfMsg.Operat == Msg_AgarSelf.Dead)
            {
                this.RemoveChild(Player);
                Player = null;

                // 玩家重生
                string RdName   = "TestName-" + RandomMaker.NextString(5);
                var bornMsg     = new Msg_AgarBorn();
                bornMsg.UserId  = Uid;
                bornMsg.Name    = RdName;
                Name            = RdName;

                client.SendMessage(bornMsg);
            }
        }