/// <summary> /// Lọc ack cho từ ứng dụng /// </summary> /// <param name="msg"></param> public void AcceptAck(QHMessage msg) { App app = Application.Current as App; if (myAccept == 1) { if (myAccJoinClub != null) { Services.Service.Instiance().ClubModel.MyClub.Numbers.Add(myAccJoinClub.IdNumberID); Services.Service.Instiance().ClubModel.MyClub.Requests.Remove(myAccJoinClub.IdNumberID); Services.Service.Instiance().ClubModel.MyClub.ReloadReative(); app.ListAccInClub.Remove(myAccJoinClub); ListRequest.Remove(myAccJoinClub); myAccJoinClub = null; NotifiDialog.Initiance().DialogAccept(); } } else { if (myAccJoinClub != null) { Services.Service.Instiance().ClubModel.MyClub.Requests.Remove(myAccJoinClub.IdNumberID); //Services.Service.Instiance().ClubModel.MyClub.ReloadReative(); app.ListAccInClub.Remove(myAccJoinClub); ListRequest.Remove(myAccJoinClub); myAccJoinClub = null; } } }
/// <summary> /// Thực hiện chức năng kết bạn nếu chưa là bạn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TapGestureRecognizer_Tapped(object sender, EventArgs e) { var stack = sender as StackLayout; stack.BackgroundColor = Color.Gray; Device.StartTimer(TimeSpan.FromMilliseconds(100), () => { stack.BackgroundColor = Color.White; return(false); }); var parent = (Accountlocal)stack.BindingContext; if (model != null && parent != null) { if (parent.AddFriend.Equals("chat.png")) { AddFriendAction.NavigationChat(this, Helper.Instance().ConvertAccsToAcc(parent)); } else if (parent.AddFriend.Equals("person_add_invi.png")) { NotifiDialog.Initiance().DialogAwaitAcceptFriend(); } else if (parent.AddFriend.Equals("person_add.png")) { AddFriendAction.AddFriend((uint)Helpers.Helper.Instance().MyAccount.Number_Id, (uint)parent.Number_Id); } } }
/// <summary> /// thực hiện login vào hệ thống /// </summary> /// <param name="PhoneNumber"></param> /// <param name="PassWord"></param> public void loginExe(string PhoneNumber, string PassWord) { QHMessage msg = new QHMessage((ushort)Chat.ChatMessage.MSG_LOGIN_REQ); msg.SetAt((byte)Chat.MsgLoginReqArg.PhoneNumber, new QHString(PhoneNumber)); msg.SetAt((byte)Chat.MsgLoginReqArg.MD5Password, new QHString(MD5.MD5.GetMd5String(PassWord))); msg.SetAt((byte)Chat.MsgLoginReqArg.DeviceID, CrossDeviceInfo.Current.Id); if (!Services.Service.Instiance().SendMessage(msg)) { NotifiDialog.Initiance().DialogErrorInternter(); } }
/// <summary> /// Hủy thách đấu club /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete(object sender, EventArgs e) { var btn = sender as Button; var parent = btn.BindingContext as ChallengeInfo; if (parent != null) { ChallengeAction.AcceptOrCancelChall(parent.ChallengeID, 0); model.Notifi.ListChallengesClub.Remove(parent); model.Notifi.count--; model.Notifi.notify = model.Notifi.count.ToString(); ChallengeAction.ListSendClub.Remove(parent.SenderID); NotifiDialog.Initiance().DialogChallengeDelete(); } }
private void TapLogin(object sender, EventArgs e) { if (Phone.Text == null || Phone.Text.Equals("")) { NotifiDialog.Initiance().DialogErrorNumber(); return; } if (PassWord.Text == null || PassWord.Text.Equals("")) { NotifiDialog.Initiance().DialogErrorPassWord(); return; } if (model != null) { model.loginExe(Phone.Text, PassWord.Text); } }
/// <summary> /// ấn hủy thách đấu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Clicked_1(object sender, EventArgs e) { var btn = sender as Button; var parent = btn.BindingContext as ChallengeInfo; if (parent != null) { ChallengeAction.AcceptOrCancelChall(parent.ChallengeID, 0); model.Notifi.ListChallengesPer.Remove(parent); ChallengeAction.ListSendAcc.Remove(parent.SenderID); model.Notifi.count--; model.Notifi.notify = model.Notifi.count.ToString(); parent.IsVisibleAccept = false; parent.IsvisibleDelete = false; NotifiDialog.Initiance().DialogChallengeDelete(); } }
/// <summary> /// Chọn tìm kiếm trong bảng search /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Search_SearchButtonPressed(object sender, EventArgs e) { if (ListAutoComplete.Count != 0) { if (lvAutoComplete.IsVisible) { lvAutoComplete.IsVisible = false; lvAutoComplete.BackgroundColor = Color.Transparent; } itemseleted = ListAutoComplete[0]; MySearch.Text = itemseleted.TextShow; model.SearchLocation.SearchAreaExe(itemseleted); lvAutoComplete.IsVisible = false; lvAutoComplete.BackgroundColor = Color.Transparent; itemseleted = null; } else { NotifiDialog.Initiance().DialogErrorArea(); } }
protected override void OnAppearing() { AppChat.Helpers.Helper.Instiance().TurnOffGesture(); base.OnAppearing(); doubclick = false; MessagingCenter.Subscribe <App, long>((App)Application.Current, "NotifiAccept", (send, arg) => { // Thay đổi giao diện khi có thay đổi Helper.Instance().addFriendStatus[arg].statusIcon = "chat.png"; NotifiDialog.Initiance().DialogtrustFriend(); }); MessagingCenter.Subscribe <App, long>((App)Application.Current, "NotifiDelete", (send, arg) => { // Thay đổi giao diện khi có thay đổi Helper.Instance().addFriendStatus[arg].statusIcon = "person_add.png"; NotifiDialog.Initiance().DialogDeleteFriend(); }); if (model == null) { model = BindingContext as SearchLocationPageViewModel; } if (model != null) { if (lvAutoComplete.IsVisible) { lvAutoComplete.IsVisible = false; lvAutoComplete.BackgroundColor = Color.Transparent; } if (!checkFirst) { ChangeTab(true); checkFirst = true; } } // đăng ký sự kiện lấy danh sách các clubId Helper.Instance().GetClubIdAck += GetListClubId; // Đăng ký sự kiện lấy club Helper.Instance().GetClubAck += GetClub; }
/// <summary> /// Kết Bạn /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Clicked(object sender, EventArgs e) { if (Helpers.Helper.Instance().IsFriend(model.NumberId).Equals("Bạn bè")) { NotifiDialog.Initiance().DialogtrustFriend(); } else if (Helpers.Helper.Instance().IsFriend(model.NumberId).Equals("Đợi chấp nhận")) { NotifiDialog.Initiance().DialogAwaitAcceptFriend(); } else if (Helpers.Helper.Instance().IsFriend(model.NumberId).Equals("Chấp nhận")) { if (model != null) { AppChat.Services.Service.Instiance().requestAddFriendViewModel.AcceptAction(Helper.Instance().ConvertAccsToAcc(model.Acc)); } } else { Helper.Instance().listAccFriendDetail.Add(model.Acc); AddFriendAction.AddFriend((uint)Helpers.Helper.Instance().MyAccount.Number_Id, (uint)model.NumberId); } }
public void RegisterProcess(QHMessage msg) { Chat.RegisterErrorCode ErrorCode = (Chat.RegisterErrorCode)(msg.GetAt((byte)Chat.MsgRegisterAckArg.ErrorCode) as QHNumber).value; switch (ErrorCode) { case Chat.RegisterErrorCode.SUCCESS: { UserDialogs.Instance.Toast("Bạn đã đăng ký thành công tài khoản"); // Nếu đăng ký thành công thì gửi bản tin Login lên Server luôn if (!PhoneNumber.Equals("") && !PassWord.Equals("")) { QHMessage msgLogin = new QHMessage((ushort)Chat.ChatMessage.MSG_LOGIN_REQ); msgLogin.SetAt((byte)Chat.MsgLoginReqArg.PhoneNumber, new QHString(PhoneNumber)); msgLogin.SetAt((byte)Chat.MsgLoginReqArg.MD5Password, new QHString(MD5.MD5.GetMd5String(PassWord))); msgLogin.SetAt((byte)Chat.MsgLoginReqArg.DeviceID, CrossDeviceInfo.Current.Id); if (!Services.Service.Instiance().SendMessage(msgLogin)) { NotifiDialog.Initiance().DialogErrorInternter(); } } else { NotifiDialog.Initiance().DialogErrorNumber(); } break; } case Chat.RegisterErrorCode.ERR_PHONE_IN_USED: { Device.BeginInvokeOnMainThread(() => { NotifiDialog.Initiance().DialogExistPhoneNumber(); }); break; } } }
private void ItemPerView_TapFriend(object sender, System.EventArgs e) { var stack = sender as StackLayout; var parent = (Accountlocal)stack.BindingContext; if (model != null && parent != null) { if (Helper.Instance().addFriendStatus[parent.Number_Id].statusIcon.Equals("chat.png")) { AddFriendAction.NavigationChat(this, Helper.Instance().ConvertAccsToAcc(parent)); } else if (Helper.Instance().addFriendStatus[parent.Number_Id].statusIcon.Equals("person_add_invi.png")) { NotifiDialog.Initiance().DialogAwaitAcceptFriend(); } else if (Helper.Instance().addFriendStatus[parent.Number_Id].statusIcon.Equals("person_add.png")) { Helper.Instance().listAddFriend.Add(parent); AddFriendAction.AddFriend((uint)Helper.Instance().MyAccount.Number_Id, (uint)parent.Number_Id); NotifiDialog.Initiance().DialogSendAddFriend(); } } // parent = null; }
public static void OnReciveAckChall(QHMessage msg) { long Error = 0; // QHNumber long ChallengeID = 0; // QHNumber(ID của lời mời) long SeqID = 0; // QHNumber(ID tự sinh do client gửi lên trong MsgInviteChallengeReqArg) long RemainTime = 0; // QHNumber (Thời gian đếm ngược tính bằng giây khi có thể gửi lời mời thách đấu tiếp theo) if (msg.TryGetAt((byte)MsgInviteChallengeAckArg.Error, ref Error)) { } if (msg.TryGetAt((byte)MsgInviteChallengeAckArg.ChallengeID, ref ChallengeID)) { } if (msg.TryGetAt((byte)MsgInviteChallengeAckArg.SeqID, ref SeqID)) { } if (msg.TryGetAt((byte)MsgInviteChallengeAckArg.RemainTime, ref RemainTime)) { } var ChallengeError = (InviteChallengeError)Error; switch (ChallengeError) { case InviteChallengeError.SUCCESS: if (SeqIDs.ContainsKey(SeqID)) { var Chall = SeqIDs[SeqID]; //thực hiện thách đấu với cá nhân if (Chall.TargetType == 0) { if (Helpers.Helper.Instance().ListAcclocal.ContainsKey(Chall.TargetID)) { Helpers.Helper.Instance().ListAcclocal[Chall.TargetID].Challenge = "pingpong_invi.png"; NotifiDialog.Initiance().DialogChallengePer(Helpers.Helper.Instance().ListAcclocal[Chall.TargetID].fullname); if (!SeqIDsAccTarget.ContainsKey(Chall.TargetID)) { SeqIDsAccTarget.Add(Chall.TargetID, SeqID); ListAccRecive.Add(Chall.TargetID, Chall); } } } //thực hiện thách đấu với club else { if (Helpers.Helper.Instance().ListClub.ContainsKey(Chall.TargetID)) { Helpers.Helper.Instance().ListClub[Chall.TargetID].Challenge = "pingpong_invi.png"; NotifiDialog.Initiance().DialogChallengeClub(Helpers.Helper.Instance().ListClub[Chall.TargetID].ClubName); if (!SeqIDsClubTarget.ContainsKey(Chall.TargetID)) { SeqIDsClubTarget.Add(Chall.TargetID, SeqID); ListClubRecive.Add(Chall.TargetID, Chall); } } } AppChat.Helpers.Helper.Instiance().UpdateProfileFinish?.Invoke(); } break; case InviteChallengeError.ERR_TOO_FREQUENTLY: break; } }
public void SendAccept(AccJoinClub accJoinClub, int accept) { QHMessage msg = new QHMessage((ushort)PingPongMsg.MSG_CLUB_JOIN_ACCEPT_REQ); if (accJoinClub != null) { //id của người được chấp nhận if (accJoinClub.IdNumberID > 0) { msg.SetAt((byte)MsgClubJoinAcceptReqArg.NumberID, new QHNumber(accJoinClub.IdNumberID)); } else { return; } //tên của người được chấp nhận if (!accJoinClub.FullName.Equals("")) { msg.SetAt((byte)MsgClubJoinAcceptReqArg.FullName, new QHString(accJoinClub.FullName)); } else { return; } //avatar của người được chấp nhận if (!accJoinClub.Avatar.Equals("")) { msg.SetAt((byte)MsgClubJoinAcceptReqArg.Avatar, new QHString(accJoinClub.Avatar)); } else { return; } //id của club chấp nhận if (accJoinClub.ClubID > 0) { msg.SetAt((byte)MsgClubJoinAcceptReqArg.ClubID, new QHNumber(accJoinClub.ClubID)); } else { return; } //cover của club chấp nhận yêu cầu if (!accJoinClub.ClubCover.Equals("")) { msg.SetAt((byte)MsgClubJoinAcceptReqArg.ClubCover, new QHString(accJoinClub.ClubCover)); } else { return; } msg.SetAt((byte)MsgClubJoinAcceptReqArg.AcceptTime, new QHString(DateTime.Now.ToLongDateString())); msg.SetAt((byte)MsgClubJoinAcceptReqArg.Accept, new QHNumber(accept)); if (!Services.Service.Instiance().SendMessage(msg)) { NotifiDialog.Initiance().DialogErrorInternter(); } else { myAccJoinClub = accJoinClub; myAccept = accept; } } }
protected override void OnAppearing() { AppChat.Helpers.Helper.Instiance().TurnOffGesture(); base.OnAppearing(); if (model == null) { model = BindingContext as DetailPersonPageViewModel; } MessagingCenter.Subscribe <App, Accounts>((App)Application.Current, "NotifiContact", (sender, arg) => { if (model != null) { if (model.Acc.Number_Id == arg.Number_Id) { Device.BeginInvokeOnMainThread(() => { btnStatue.Text = "Đợi chấp nhận"; string avartaStatus = Helper.Instance().IsFriendImg(model.Acc.Number_Id); if (!Helper.Instance().addFriendStatus.ContainsKey(model.Acc.Number_Id)) { IconAddFriend iconAddFriend = new IconAddFriend() { id = model.Acc.Number_Id, statusIcon = avartaStatus }; Helper.Instance().addFriendStatus.Add(model.Acc.Number_Id, iconAddFriend); } else { Helper.Instance().addFriendStatus[model.Acc.Number_Id].statusIcon = avartaStatus; } UserDialogs.Instance.Toast("Gửi kết bạn thành công, vui lòng chờ phản hồi"); // NotifiDialog.Initiance().DialogAwaitFriend(); }); } } }); MessagingCenter.Subscribe <App, long>((App)Application.Current, "NotifiAccept", (send, arg) => { if (model != null) { if (model.Acc.Number_Id == arg) { //string avartaStatus = Helper.Instance().IsFriendImg(model.Acc.Number_Id); //if (!Helper.Instance().addFriendStatus.ContainsKey(model.Acc.Number_Id)) // Helper.Instance().addFriendStatus.Add(model.Acc.Number_Id, avartaStatus); //else Helper.Instance().addFriendStatus[model.Acc.Number_Id] = avartaStatus; Device.BeginInvokeOnMainThread(() => { btnChat.Text = "Tin nhắn"; btnStatue.Text = "Bạn bè"; NotifiDialog.Initiance().DialogtrustFriend(); }); } } }); MessagingCenter.Subscribe <App, long>((App)Application.Current, "NotifiDelete", (send, arg) => { if (model != null) { if (model.Acc.Number_Id == arg) { //string avartaStatus = Helper.Instance().IsFriendImg(model.Acc.Number_Id); //if (!Helper.Instance().addFriendStatus.ContainsKey(model.Acc.Number_Id)) // Helper.Instance().addFriendStatus.Add(model.Acc.Number_Id, avartaStatus); //else Helper.Instance().addFriendStatus[model.Acc.Number_Id] = avartaStatus; Device.BeginInvokeOnMainThread(() => { btnChat.Text = "Tin nhắn"; btnStatue.Text = "Gửi Kết bạn"; NotifiDialog.Initiance().DialogDeleteFriend(); }); } } }); }
/// <summary> /// chức năng xem thêm thông tin thi đấu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TapGestureRecognizer_Tapped(object sender, EventArgs e) { NotifiDialog.Initiance().DialogDevelop(); }