Beispiel #1
0
        private static void SysMessHandler(GetSysMessResponseModel responseModel)
        {
            int MessType = responseModel.sysMessType;

            if (MessType == 0 || MessType == 1 || MessType == 2 || MessType == 3)
            {
                mainForm.Invoke(new Action(() =>
                {
                    SysMessForm requestForm = new SysMessForm(responseModel);
                    requestForm.Show();
                }));
                if (MessType == 2)
                {
                    GetFriendsRequestModel requestModel = new GetFriendsRequestModel();
                    requestModel.targetId = responseModel.fromId;
                    GetFriends(requestModel, mainForm);
                }
            }
            else if (MessType == 4)
            {
                if (mainForm != null)
                {
                    mainForm.OffLineFriend(responseModel.fromId);
                }
            }
            else if (MessType == 5)
            {
                if (mainForm != null)
                {
                    mainForm.OnLineFriend(responseModel.fromId);
                    GetFriendsRequestModel requestModel = new GetFriendsRequestModel();
                    requestModel.targetId = responseModel.fromId;
                    GetFriends(requestModel, mainForm);
                }
            }
        }
Beispiel #2
0
 public SysMessForm(GetSysMessResponseModel sysMessModel)
 {
     InitializeComponent();
     this.sysMessModel = sysMessModel;
     ShowInfo();
 }
Beispiel #3
0
 private static void Ws_OnMessage(object sender, MessageEventArgs e)
 {
     try {
         string     json         = e.Data;
         CommonMess responseMess = JsonHelper.DeserializeObject <CommonMess>(json);
         int        messType     = -responseMess.messType;
         if (messType == MessType.AddFriend)
         {
             searchFormFriend.AddFriendOK();
         }
         else if (messType == MessType.AgreeAddFriend)
         {
         }
         else if (messType == MessType.GetFriends)
         {
             GetFriendsResponseModel responseModel = JsonHelper.DeserializeObject <GetFriendsResponseModel>(responseMess.content);
             mainForm.GetFriendsRespondeHandler(responseModel);
         }
         else if (messType == MessType.GetOffLineChatMess)
         {
             GetOffLineChatMessResponseModel responseModel = JsonHelper.DeserializeObject <GetOffLineChatMessResponseModel>(responseMess.content);
             mainForm.GetOffLineChatMessHandler(responseModel);
         }
         else if (messType == MessType.GetSysMess)
         {
             GetSysMessResponseModel responseModel = JsonHelper.DeserializeObject <GetSysMessResponseModel>(responseMess.content);
             SysMessHandler(responseModel);
         }
         else if (messType == MessType.Login)
         {
             LoginResponseModel responseModel = JsonHelper.DeserializeObject <LoginResponseModel>(responseMess.content);
             SystemHelper.currentUser = responseModel;
             loginForm.LoginOK(responseModel);
         }
         else if (messType == MessType.LoginOut)
         {
         }
         else if (messType == MessType.Register)
         {
             RegisetResponseModel responseModel = JsonHelper.DeserializeObject <RegisetResponseModel>(responseMess.content);
             registerForm.RegisterOK(responseModel);
         }
         else if (messType == MessType.SearchFriend)
         {
             SearchFriendResponseModel responseModel = JsonHelper.DeserializeObject <SearchFriendResponseModel>(responseMess.content);
             searchFormFriend.SerarchFriendsResult(responseModel);
         }
         else if (messType == MessType.SendChatMess)
         {
         }
         else if (messType == MessType.EditInfo)
         {
             EditInfoResponseModel respondeModel = JsonHelper.DeserializeObject <EditInfoResponseModel>(responseMess.content);
             if (respondeModel.state == 1)
             {
                 SystemHelper.currentUser.age      = respondeModel.age;
                 SystemHelper.currentUser.blood    = respondeModel.blood;
                 SystemHelper.currentUser.conste   = respondeModel.conste;
                 SystemHelper.currentUser.faceimg  = respondeModel.faceimg;
                 SystemHelper.currentUser.gender   = respondeModel.gender;
                 SystemHelper.currentUser.nickname = respondeModel.nickname;
                 if (mainForm != null && mainForm.IsHandleCreated)
                 {
                     mainForm.Invoke(new Action(() => {
                         mainForm.ShowSelfInfo();
                     }));
                     Application.DoEvents();
                 }
             }
             else
             {
                 MessageBox.Show("用户信息修改失败!");
             }
         }
     }
     catch (Exception err) {
         MessageBox.Show(err.ToString(), "OnMessageError");
     }
 }