public void AddFriend() { AddFriendRequest request = new AddFriendRequest(); request.FriendUsername = friendrequestText.text; PlayFabClientAPI.AddFriend(request, result => { Alerts a = new Alerts(); StartCoroutine(a.CreateNewAlert("Added friend: " + friendrequestText.text)); GameObject[] curFriends = GameObject.FindGameObjectsWithTag("Friend"); foreach (GameObject friend in curFriends) { GameObject.Destroy(friend); } GetFriends(); }, error => { Alerts a = new Alerts(); StartCoroutine(a.CreateNewAlert(error.ErrorMessage)); Debug.Log(error.ErrorMessage); }); }
public ChatResult AddFriendRespond(string requestId, bool agree) { AddFriendRequest request = Manager.Instance.GetFriendRequestById(requestId); if (request == null) { return(new ChatResult(false, "Request not found")); } CustomerInfo myCustomer = Manager.Instance.GetCustomerByCustomerId(request.Receiver); CustomerInfo friendCustomer = Manager.Instance.GetCustomerByCustomerId(request.Sender); CustomerInfo returnMyCustomer = new CustomerInfo(myCustomer.CustomerId, myCustomer.CustomerName, myCustomer.Status); CustomerInfo returnFriendCustomer = new CustomerInfo(friendCustomer.CustomerId, friendCustomer.CustomerName, friendCustomer.Status); ChatResult result = Manager.Instance.AddFriendRespond(Context.ConnectionId, requestId, agree); if (result.Success) { //send to request customer Clients.Clients(friendCustomer.ConnectionList).OnAddFriendRespond(returnMyCustomer, agree); if (agree) { //send to respond customer Clients.Clients(myCustomer.ConnectionList).OnAddFriendRespond(returnFriendCustomer, agree); } } return(result); }
public override Task <AddFriendResponse> AddFriend(AddFriendRequest request, ServerCallContext context) { _friendsService.AddFriend(Guid.Parse(request.UserId), Guid.Parse(request.FriendId)); var response = new AddFriendResponse(); return(Task.FromResult(response)); }
/// <summary> /// フレンドを登録する。 /// </summary> /// <param name="playFabId"></param> /// <returns></returns> public static async UniTask <(bool isSuccess, string message)> AddFriendAsync(string playFabId) { if (Friends.Count >= FriendLimitNum) { return(false, $"フレンドの人数が上限に達しています。"); } var request = new AddFriendRequest { FriendPlayFabId = playFabId }; var response = await PlayFabClientAPI.AddFriendAsync(request); if (response.Error != null) { switch (response.Error.Error) { case PlayFabErrorCode.AccountNotFound: case PlayFabErrorCode.InvalidParams: return(false, "指定されたユーザーが見つかりませんでした。"); case PlayFabErrorCode.UsersAlreadyFriends: return(false, "既にフレンドになっているユーザーです。"); default: throw new PlayFabErrorException(response.Error); } } return(true, "フレンドを追加しました。"); }
public async Task <AddFriendResponse> AddFriend(AddFriendRequest request) { AddFriendResponse addFriendResponse = new AddFriendResponse(); try { addFriendResponse = (await App.Database.AddFriend(new AddFriendRequest { Username = request.Username })); } catch (Exception e) { var exception = JsonConvert.DeserializeObject <ErrorMsg>(e.Message); switch (exception.err) { case ErrorType.PersonAlreadyFriend: await _dialogService.ShowMessage($"Friend request already sent", "Error", "OK", null); break; default: await _dialogService.ShowMessage($"The server returned an error: {e.Message}", "Error", "OK", null); break; } } return(addFriendResponse); }
public AddFriendRequest MapFriendRequestById(IDataReader record) { if (record.Read()) { AddFriendRequest request = new AddFriendRequest(); if (record["ID"] != DBNull.Value) { request.Id = record["ID"].ToString(); } if (record["SenderID"] != DBNull.Value) { request.Sender = record["SenderID"].ToString(); } if (record["ReceiverID"] != DBNull.Value) { request.Receiver = record["ReceiverID"].ToString(); } if (record["DateTime"] != DBNull.Value) { request.Datetime = (DateTime)record["DateTime"]; } return(request); } return(null); }
private void AddFriend(FriendIDType idType, string friendPlayFabID) { var Request = new AddFriendRequest(); switch (idType) { case FriendIDType.PlayFabId: Request.FriendPlayFabId = friendPlayFabID; break; case FriendIDType.Username: Request.FriendUsername = friendPlayFabID; break; case FriendIDType.Email: Request.FriendEmail = friendPlayFabID; break; case FriendIDType.DisplayName: Request.FriendTitleDisplayName = friendPlayFabID; break; } PlayFabClientAPI.AddFriend(Request, result => { StartCoroutine(GeneralController.Inistance.ToastDisplayer("Friend Added Successfully")); }, DisplayPlayFabError); }
void AddFriend(FriendIdType IdType, string FriendId) { var Request = new AddFriendRequest(); switch (IdType) { case FriendIdType.PlayFabId: Request.FriendPlayFabId = FriendId; break; case FriendIdType.Username: Request.FriendUsername = FriendId; break; case FriendIdType.Email: Request.FriendEmail = FriendId; break; case FriendIdType.DisplayName: Request.FriendTitleDisplayName = FriendId; break; } PlayFabClientAPI.AddFriend(Request, result => { Debug.Log("Friend Added Successfully"); }, DisplayPlayfabError); }
public async Task <ActionResult> AddFriendAsync( int id, [FromBody] AddFriendRequest request) { try { var friend = await _userManager.AddUserFriendAsync(new AddUserFriendModel { FriendId = request.UserId, UserId = id, }); return(new JsonResult(new FriendRequestResponse { Accepted = friend.Accepted, Id = friend.Id, Receiver = new BasicUserResponse { Id = friend.User2Id }, Sender = new BasicUserResponse { Id = friend.User1Id }, })); } catch (Exception ex) { _logger.LogWarning(ex, $"Could not add user ({request.UserId}) as friend to user ({id})."); return(BadRequest()); } }
public void AddFriend() { menuObject.GetComponent <Animator>().Play("hideMenuAnimation"); if (!GameManager.Instance.offlineMode) { PhotonNetwork.RaiseEvent(192, 1, true, null); AddFriendRequest request = new AddFriendRequest() { FriendPlayFabId = PhotonNetwork.otherPlayers[0].name }; //PlayFabClientAPI.AddFriend(request, (result) => //{ // Debug.Log("Added friend successfully"); // GameManager.Instance.friendButtonMenu.SetActive(false); // GameManager.Instance.smallMenu.GetComponent<RectTransform>().sizeDelta = new Vector2(GameManager.Instance.smallMenu.GetComponent<RectTransform>().sizeDelta.x, 260.0f); //}, (error) => //{ // Debug.Log("Error adding friend: " + error.Error); //}, null); } }
void AddFriend(FriendIdType idType, Text friendId) { var request = new AddFriendRequest(); switch (idType) { case FriendIdType.PlayFabId: request.FriendPlayFabId = friendId.text; break; case FriendIdType.Username: request.FriendUsername = friendId.text; break; case FriendIdType.Email: request.FriendEmail = friendId.text; break; case FriendIdType.DisplayName: request.FriendTitleDisplayName = friendId.text; break; } // Execute request and update friends when we are done PlayFabClientAPI.AddFriend(request, result => { lobbyManager.SuccessPopup("Add Friend : " + friendId, true); FriendListRefresh(); friendId.text = ""; }, error => { lobbyManager.ErrorPopup("Can't Find Friend : " + friendId, true); }); }
private async void AddFriendButton_OnClick(object sender, RoutedEventArgs e) { if (ResultsList.SelectedIndex >= 0) { if (MatchingUsers[ResultsList.SelectedIndex] != null) { AddFriendRequest r = new AddFriendRequest { logedinUser = _user.User.UserName, friendUsername = MatchingUsers[ResultsList.SelectedIndex].UserName }; Packet p = new Packet { PacketType = EPacketType.AddFriendRequest, Payload = JsonConvert.SerializeObject(r) }; TcpClient.DoRequest(p, AddFriendCallBack); } } else { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var dialog = new ContentDialog { Title = "No user selected", MaxWidth = ActualWidth }; dialog.PrimaryButtonText = "OK"; var result = await dialog.ShowAsync(); }); } }
public void AddFriendButtonClick() { if (!CurrentPlayerID.Contains("_BOT")) { AddFriendRequest request = new AddFriendRequest() { FriendPlayFabId = CurrentPlayerID, }; PlayFabClientAPI.AddFriend(request, (result) => { PhotonNetwork.RaiseEvent((int)EnumPhoton.AddFriend, PhotonNetwork.playerName + ";" + GameManager.Instance.nameMy + ";" + CurrentPlayerID, true, null); addedFriendWindow.SetActive(true); Debug.Log("Added friend successfully"); }, (error) => { addedFriendWindow.SetActive(true); Debug.Log("Error adding friend: " + error.Error); }, null); } else { Debug.Log("Add Friend - It's bot!"); addedFriendWindow.SetActive(true); } }
public void AddFriend(string friendIdType) { if (!Enum.TryParse(friendIdType, out FriendIdType idType)) { return; } var request = new AddFriendRequest(); switch (idType) { case FriendIdType.PlayFabId: request.FriendPlayFabId = friendId; break; case FriendIdType.Username: request.FriendUsername = friendId; break; case FriendIdType.Email: request.FriendEmail = friendId; break; case FriendIdType.DisplayName: request.FriendTitleDisplayName = friendId; break; } // Execute request and update friends when we are done PlayFabClientAPI.AddFriend(request, result => { Debug.Log("Friend added successfully!"); }, LogPlayFabError); UISingleton.instance.addFriendPanel.SetActive(false); }
public Dictionary <string, AddFriendRequest> MapFriendRequest(IDataReader record) { Dictionary <string, AddFriendRequest> requestList = new Dictionary <string, AddFriendRequest>(); while (record.Read()) { AddFriendRequest request = new AddFriendRequest(); if (record["ID"] != DBNull.Value) { request.Id = record["ID"].ToString(); } if (record["SenderID"] != DBNull.Value) { request.Sender = record["SenderID"].ToString(); } if (record["ReceiverID"] != DBNull.Value) { request.Receiver = record["ReceiverID"].ToString(); } if (record["DateTime"] != DBNull.Value) { request.Datetime = (DateTime)record["DateTime"]; } requestList.Add(request.Id, request); } return(requestList); }
void AddFriend(FriendIdType idType, string friendId) { var request = new AddFriendRequest(); switch (idType) { case FriendIdType.PlayFabId: request.FriendPlayFabId = friendId; break; case FriendIdType.Username: request.FriendUsername = friendId; break; case FriendIdType.Email: request.FriendEmail = friendId; break; case FriendIdType.DisplayName: request.FriendTitleDisplayName = friendId; break; } // Execute request and update friends when we are done PlayFabClientAPI.AddFriend(request, result => { Debug.Log("Friend added successfully!"); }, OnErrorShared); }
public ChatResult AddFriendRespond(string connectionId, string requestId, bool agree) { if (m_mapConnectionIdCustomer.ContainsKey(connectionId)) { if (m_AddFriendRequestDict.ContainsKey(requestId)) { AddFriendRequest request = m_AddFriendRequestDict[requestId]; CustomerInfo customer = GetCustomerByCustomerId(request.Receiver); bool isFriend = customer.FriendList.Contains(request.Sender); AddFriendRequest r; //dù agree hay refuse thì dict sẽ remove friendrequest đi m_AddFriendRequestDict.TryRemove(requestId, out r); m_adapter.DeleteFriendRequest(requestId);//dtb if (agree) { m_customerInfoDict[request.Sender].AddNewFriend(request.Receiver); m_customerInfoDict[request.Receiver].AddNewFriend(request.Sender); m_adapter.AddFriend(request.Sender, request.Receiver);//dtb } return(new ChatResult(true, null)); }//nếu requestDict ko còn nữa thì ko xử lí gì return(new ChatResult(false, "No friend request.")); } return(new ChatResult(false, "Your Id doesn't exist.")); }
public static void AddFriend(string input, AddFriendMethod method, UnityAction <bool> callback = null) { var request = new AddFriendRequest(); switch (method) { case AddFriendMethod.DisplayName: request.FriendTitleDisplayName = input; break; case AddFriendMethod.Email: request.FriendEmail = input; break; case AddFriendMethod.Username: request.FriendUsername = input; break; case AddFriendMethod.PlayFabID: request.FriendPlayFabId = input; break; } DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.AddFriend); PlayFabClientAPI.AddFriend(request, result => { if (callback != null) { callback(result.Created); } PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.AddFriend, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
/// <summary> /// 创建实例 /// </summary> public static AddFriendRequest create(long playerID, int type) { AddFriendRequest re = (AddFriendRequest)BytesControl.createRequest(dataID); re.playerID = playerID; re.type = type; return(re); }
private void handleaddplayfabfriend(string name) { var request = new AddFriendRequest { FriendTitleDisplayName = name }; PlayFabClientAPI.AddFriend(request, onfriendaddedsucess, onfailure); }
private void HandleAddPlayerFriend(string name) { var request = new AddFriendRequest { FriendTitleDisplayName = name }; PlayFabClientAPI.AddFriend(request, OnFriendAddedSuccess, OnFailure); }
public void AddFriend(int id, AddFriendRequest request) { var userProfile = _repository.Load(id); var friendUserProfile = _repository.Load(request.FriendUserId); userProfile.AddFriend(request.FriendUserId); friendUserProfile.AddFriend(id); _unitOfWork.Commit(); }
public void AddFriend() { if (friendToFindName.Length > 0) { AddFriendRequest request = new AddFriendRequest(); request.FriendTitleDisplayName = friendToFindName; PlayFabClientAPI.AddFriend(request, OnFriendAdded, OnPlayFabError); friendToFindInputField.text = ""; } }
public AddFriendResponse AddFriend(AddFriendRequest input) { if (!this.ModelState.IsValid) { return new AddFriendResponse { Status = new Status { Code = Status.INTERNAL_MESSAGE_CODE, Message = this.ModelState.Values.First().Errors.First().ErrorMessage } }; } if (input == null) { return new AddFriendResponse(Status.MISSING_PARRAMETERS); } ////check for register user by Token User currentUser = null; try { currentUser = this.Users.SingleOrDefault(a => a.Token == input.Token); ////TOKEN must be unique if (currentUser == null) { return new AddFriendResponse(Status.INVALID_TOKEN); } } catch (Exception) { return new AddFriendResponse(Status.INTERNAL_ERROR); } ////check for exist friend var friends = currentUser.Friends; if (friends.Count > 0) { var friend = friends.FirstOrDefault(a => a.Email == input.Email); if (friend != null) { return new AddFriendResponse(Status.ADDFRIEND_EXIST); } } friends.Add(new Friend { Nickname = input.Nickname, Email = input.Email }); this.Users.Update(currentUser); return new AddFriendResponse(Status.ADDFRIEND_SUCCESSFULL_ADDED); }
public void AddFriend(AddFriendRequest addFriendRequest) { using var db = new RabbitChatContext(); var sendingUser = db.RabbitUsers.Include(x => x.Friends) .Single(user => user.RabbitUserId == addFriendRequest.SendingUserId); var requestedUser = db.RabbitUsers.Include(x => x.Friends) .Single(user => user.Username == addFriendRequest.RequestedFriendUsername); sendingUser.Friends.Add(requestedUser); db.SaveChanges(); }
public async Task <AddFriendResponse> AddFriend(AddFriendRequest request) { string json = JsonConvert.SerializeObject(request, _settings); HttpResponseMessage res = await _client.PutAsync($"person/{request.Username}/friend", new StringContent(json, Encoding.UTF8, "application/json")); var content = await res.Content.ReadAsStringAsync(); EnsureSuccessStatusCode(res, content); var addFriendResponse = JsonConvert.DeserializeObject <AddFriendResponse>(content); return(addFriendResponse); }
public ActionResult AddFriends(AddFriendRequest addFriendRequest, int id) { if (!_validator.ValidateAddFriends()) { return(BadRequest()); } var user = _memberRepo.GetMember(id); user.Friends.Add(addFriendRequest.FriendId); var friends = user.GetFriends(); return(Accepted($"api/members/{user.Id}/friends", friends)); }
public ChatResult <AddFriendRequest> AddFriendRequest(string friendId) { ChatResult <AddFriendRequest> result = Manager.Instance.AddFriendRequest(Context.ConnectionId, friendId); if (result.Success) { AddFriendRequest request = result.Data; List <string> friendConnectionIds = Manager.Instance.GetCustomerByCustomerId(friendId).ConnectionList; Clients.Clients(friendConnectionIds).OnAddFriendRequest(new List <AddFriendRequest>() { request }); } return(result); }
public AddFriendRequest GetFriendRequestById(string requestId) { if (m_AddFriendRequestDict.ContainsKey(requestId)) { return(m_AddFriendRequestDict[requestId]); } else { AddFriendRequest request = m_adapter.GetFriendRequestById(requestId); if (request != null) { return(request); } } return(null); }
/// <summary> /// Function to add a friend in PlayFab /// </summary> /// <param name="friendId"></param> public void AddFriend(string friendId) { var request = new AddFriendRequest { FriendPlayFabId = friendId }; // Execute request and update friends when we are done PlayFabClientAPI.AddFriend(request, result => { Debug.Log("Friend added successfully!"); }, OnFailure); UpdateFriendsList(); UpdateFriendsLeaderboard(); }
public bool AddFriendRequest(AddFriendRequest request) { string query = "CHAT.FRIENDREQUEST_CREATE"; try { OracleDataHelper helper = OracleHelper; helper.BeginTransaction(); helper.ExecuteNonQuery(query, request.Id, request.Sender, request.Receiver, request.Datetime); helper.Commit(); } catch (Exception ex) { OracleHelper.Rollback(); throw ex; } return(true); }