Beispiel #1
0
        public void OnReceiveMsg(ReceiveMsgOrder receiveMsgOrder)
        {
            string[] msg = null;
            if (receiveMsgOrder.MsgContent.IndexOf(MessageTypes.NSP) > -1)
            {
                msg = receiveMsgOrder.MsgContent.Split(MessageTypes.NSP.ToCharArray());
            }

            // ilogger.Logger(string.Format("接收到的数据:{0}-{1}", receiveMsgOrder.ModuleType, receiveMsgOrder.MsgContent));
            if (receiveMsgOrder.Sign == 0)
            {
                XWT.MessageBox.Show(receiveMsgOrder.MsgContent, "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }

            switch (receiveMsgOrder.ModuleType)
            {
                #region 返回个人信息_PER
            case MessageTypes.PER:

                this.UserID   = msg[0];
                this.CardWord = msg[1];
                this.UserName = msg[2];
                this.ImgSrc   = msg[3];

                //存储用户信息
                this.regionManager.Regions[RegionTypes.CardRegion].Context = msg;

                break;
                #endregion

                #region 返回游戏成就_ACH
            case MessageTypes.ACH:

                //更新
                foreach (AchieveViewModel viewmodel in achieveList)
                {
                    if (viewmodel.GameName == msg[0])
                    {
                        viewmodel.Level  = msg[1];
                        viewmodel.Rank   = msg[2];
                        viewmodel.Total  = msg[3];
                        viewmodel.Single = msg[4];

                        return;
                    }
                }

                //添加
                _achieveModel = AchieveModel.CreateModel(msg[0], msg[1], msg[2], msg[3], msg[4]);
                achieveList.Add(new AchieveViewModel(_achieveModel));
                //this.AllAchieves.Add(new AchieveViewModel(_achieveModel));

                this.Achieve++;
                ChangePage(this._pagingAchieve.CurrentPage == 0 ? 1 : this._pagingAchieve.CurrentPage, Paging.ACH, this._pagingAchieve);

                break;
                #endregion

                #region 返回消息_MSG
            case MessageTypes.MSG:

                string msginfo = msg[0] + "," + GetString.GetRandomCode(GetString.Code.StrAndNum, 4);

                _msgModel = MsgModel.CreateModel(msginfo, msg[0], msg[1], msg[2], msg[3]);
                msgList.Add(new MsgViewModel(_msgModel));

                this.Message++;
                ChangePage(this._pagingMsg.CurrentPage == 0 ? 1 : this._pagingMsg.CurrentPage, Paging.MSG, this._pagingMsg);

                break;
                #endregion

                #region 修改密码返回的信息_SET
            case MessageTypes.SET:

                this.PassWord    = "";
                this.NewPassWord = "";
                this.ConPassWord = "";

                XWT.MessageBox.Show(receiveMsgOrder.MsgContent, "提示", MessageBoxButton.OK, MessageBoxImage.Information);

                break;
                #endregion

                #region 返回好友信息_FRI
            case MessageTypes.FRI:

                switch (msg[5])
                {
                case MessageTypes.Friend:

                    _friendModel = FriendModel.CreateModel(msg[0], msg[1], msg[2], msg[3], msg[5], msg[4] == MessageTypes.N ? true : false, msg[4] == MessageTypes.N ? false : true);
                    this.AllFriends.Add(new FriendViewModel(_friendModel));

                    this.Friend++;

                    break;

                case MessageTypes.Family:

                    _familyModel = FamilyModel.CreateModel(msg[0], msg[1], msg[2], msg[3], msg[5], msg[4] == MessageTypes.N ? true : false, msg[4] == MessageTypes.N ? false : true);
                    this.AllFamilys.Add(new FamilyViewModel(_familyModel));

                    this.Friend++;

                    break;

                case MessageTypes.Black:

                    _blackModel = BlackModel.CreateModel(msg[0], msg[1], msg[2], msg[3], msg[5], msg[4] == MessageTypes.N ? true : false, false);
                    this.AllBlacks.Add(new BlackViewModel(_blackModel));

                    this.Friend++;

                    break;
                }

                break;
                #endregion

                #region 返回查找好友结果_SFR
            case MessageTypes.SFR:

                _resultModel = ResultModel.CreateModel(msg[0], msg[1], msg[2], msg[3],
                                                       msg[1] == this.CardWord ? false : true, msg[4] == MessageTypes.N ? true : false);
                this.AllResults.Add(new ResultViewModel(_resultModel));

                break;
                #endregion

                #region 好友上线通知_UPL
            case MessageTypes.UPL:

                foreach (FriendViewModel friend in this.AllFriends.Where(f => f.FriendID == receiveMsgOrder.MsgContent))
                {
                    friend.FriendStatus  = false;
                    friend.MenuIsEnabled = true;
                }

                foreach (FamilyViewModel family in this.AllFamilys.Where(f => f.FriendID == receiveMsgOrder.MsgContent))
                {
                    family.FriendStatus  = false;
                    family.MenuIsEnabled = true;
                }

                break;
                #endregion

                #region 好友下线通知_OFF
            case MessageTypes.OFF:

                foreach (FriendViewModel friend in this.AllFriends.Where(f => f.FriendID == receiveMsgOrder.MsgContent))
                {
                    friend.FriendStatus  = true;
                    friend.MenuIsEnabled = false;
                }

                foreach (FamilyViewModel family in this.AllFamilys.Where(f => f.FriendID == receiveMsgOrder.MsgContent))
                {
                    family.FriendStatus  = true;
                    family.MenuIsEnabled = false;
                }

                break;
                #endregion

                #region 询问好友添加请求_ASK
            case MessageTypes.ASK:

                string msginfo1 = MessageTypes.F + "," + GetString.GetRandomCode(GetString.Code.StrAndNum, 4) + "," + msg[0];

                _msgModel = MsgModel.CreateModel(msginfo1, MessageTypes.F, "请求添加您为好友.", "", msg[1]);
                msgList.Add(new MsgViewModel(_msgModel));

                this.Message++;
                ChangePage(this._pagingMsg.CurrentPage == 0 ? 1 : this._pagingMsg.CurrentPage, Paging.MSG, this._pagingMsg);

                break;
                #endregion

                #region 返回查找好友资料进行添加_AGR
            case MessageTypes.AGR:

                //添加信息提示
                string msginfo2 = MessageTypes.T + "," + GetString.GetRandomCode(GetString.Code.StrAndNum, 4);

                _msgModel = MsgModel.CreateModel(msginfo2, MessageTypes.T, "对方同意您的添加请求.", "", msg[1]);
                msgList.Add(new MsgViewModel(_msgModel));

                this.Message++;
                ChangePage(this._pagingMsg.CurrentPage == 0 ? 1 : this._pagingMsg.CurrentPage, Paging.MSG, this._pagingMsg);

                //添加好友
                _friendModel = FriendModel.CreateModel(msg[0], msg[1], msg[2], msg[3], msg[5], msg[4] == MessageTypes.N ? true : false, msg[4] == MessageTypes.N ? false : true);
                this.AllFriends.Add(new FriendViewModel(_friendModel));

                this.Friend++;

                //添加信息提示
                string msginfo3 = MessageTypes.T + "," + GetString.GetRandomCode(GetString.Code.StrAndNum, 4);

                _msgModel = MsgModel.CreateModel(msginfo3, MessageTypes.T, "新的好友添加成功.", "", "系统");
                msgList.Add(new MsgViewModel(_msgModel));

                this.Message++;
                ChangePage(this._pagingMsg.CurrentPage == 0 ? 1 : this._pagingMsg.CurrentPage, Paging.MSG, this._pagingMsg);

                break;
                #endregion

                #region 返回查找好友资料进行添加_AFR
            case MessageTypes.AFR:

                //添加好友信息
                _friendModel = FriendModel.CreateModel(msg[0], msg[1], msg[2], msg[3], msg[5], msg[4] == MessageTypes.N ? true : false, msg[4] == MessageTypes.N ? false : true);
                this.AllFriends.Add(new FriendViewModel(_friendModel));

                this.Friend++;

                //添加信息提示
                string msginfo4 = MessageTypes.T + "," + GetString.GetRandomCode(GetString.Code.StrAndNum, 4);

                _msgModel = MsgModel.CreateModel(msginfo4, MessageTypes.T, "新的好友添加成功.", "", "系统");
                msgList.Add(new MsgViewModel(_msgModel));

                this.Message++;
                ChangePage(this._pagingMsg.CurrentPage == 0 ? 1 : this._pagingMsg.CurrentPage, Paging.MSG, this._pagingMsg);

                break;
                #endregion

                #region 对方将自己删除,此处也将对方删除_DFR
            case MessageTypes.DFR:

                foreach (FriendViewModel friend in this.AllFriends)
                {
                    if (friend.FriendID == receiveMsgOrder.MsgContent)
                    {
                        this.AllFriends.Remove(friend);
                        break;
                    }
                }

                if (this.Friend > 0)
                {
                    this.Friend--;
                }

                break;
                #endregion

                #region 返回移动好友结果,本地进行移动_MFR
            case MessageTypes.MFR:

                switch (msg[1])
                {
                    #region 该好友原来在“我的好友”组
                case MessageTypes.Friend:

                    foreach (FriendViewModel friend in this.AllFriends)
                    {
                        if (friend.FriendID == msg[0])
                        {
                            //从该组移除
                            this.AllFriends.Remove(friend);

                            switch (msg[2])
                            {
                            //现移动到“我的家族”
                            case MessageTypes.Family:

                                _familyModel = FamilyModel.CreateModel(friend.FriendID, friend.FriendCard, friend.FriendName, friend.FriendImg, MessageTypes.Family, friend.FriendStatus, friend.MenuIsEnabled);
                                this.AllFamilys.Add(new FamilyViewModel(_familyModel));

                                break;

                            //现移动到“黑名单”
                            case MessageTypes.Black:

                                _blackModel = BlackModel.CreateModel(friend.FriendID, friend.FriendCard, friend.FriendName, friend.FriendImg, MessageTypes.Black, friend.FriendStatus, false);
                                this.AllBlacks.Add(new BlackViewModel(_blackModel));

                                break;
                            }

                            break;
                        }
                    }

                    break;
                    #endregion

                    #region 该好友原来在“我的家族”组
                case MessageTypes.Family:

                    foreach (FamilyViewModel family in this.AllFamilys)
                    {
                        if (family.FriendID == msg[0])
                        {
                            //从该组移除
                            this.AllFamilys.Remove(family);

                            switch (msg[2])
                            {
                            //现移动到“我的好友”
                            case MessageTypes.Friend:

                                _friendModel = FriendModel.CreateModel(family.FriendID, family.FriendCard, family.FriendName, family.FriendImg, MessageTypes.Friend, family.FriendStatus, family.MenuIsEnabled);
                                this.AllFriends.Add(new FriendViewModel(_friendModel));

                                break;

                            //现移动到“黑名单”
                            case MessageTypes.Black:

                                _blackModel = BlackModel.CreateModel(family.FriendID, family.FriendCard, family.FriendName, family.FriendImg, MessageTypes.Black, family.FriendStatus, false);
                                this.AllBlacks.Add(new BlackViewModel(_blackModel));

                                break;
                            }

                            break;
                        }
                    }
                    break;
                    #endregion

                    #region 该好友原来在“黑名单”组
                case MessageTypes.Black:

                    foreach (BlackViewModel black in this.AllBlacks)
                    {
                        if (black.FriendID == msg[0])
                        {
                            //从该组移除
                            this.AllBlacks.Remove(black);

                            switch (msg[2])
                            {
                            //现移动到“我的好友”
                            case MessageTypes.Friend:

                                _friendModel = FriendModel.CreateModel(black.FriendID, black.FriendCard, black.FriendName, black.FriendImg, MessageTypes.Friend, black.FriendStatus, !black.FriendStatus);
                                this.AllFriends.Add(new FriendViewModel(_friendModel));

                                break;

                            //现移动到“我的家族”
                            case MessageTypes.Family:

                                _familyModel = FamilyModel.CreateModel(black.FriendID, black.FriendCard, black.FriendName, black.FriendImg, MessageTypes.Friend, black.FriendStatus, !black.FriendStatus);
                                this.AllFamilys.Add(new FamilyViewModel(_familyModel));

                                break;
                            }

                            break;
                        }
                    }
                    break;
                    #endregion
                }

                break;
                #endregion
            }

            //MessageBox.Show(receiveMsgOrder.MsgContent);

            //ReceiveMsgEvent msgEvent = receive_Aggregator.GetEvent<ReceiveMsgEvent>();

            //if (subscriptionToken != null)
            //    msgEvent.Unsubscribe(subscriptionToken);
        }