/// <summary> /// If you want to know the game is in progress or not /// then join that user to the game again /// </summary> /// <param name="matchId">the id of the match .</param> /// <param name="second">the minimum time left from that game.</param> /// <param name="onResult"></param> /// <returns>true , false</returns> public void IsMatchInProgressStatus(string matchId, Action <Result> onResult) { JSONObject json = new JSONObject(); json.Add("type", UpdateTypes.isMatchInProgress.ToString()); json.Add("matchId", matchId); json.Add("token", Client.Token); _socket.Emit(matchControllerEvent, json.ToString()); OnIsMatchInProgressResult = onResult; }
public void SearchFriend(string searchUsername, Action <Result> onResult) { JSONObject json = new JSONObject(); json.Add("type", FriendTypes.search.ToString()); json.Add("searchUsername", searchUsername); json.Add("token", Client.Token); _socket.Emit(friendEvent, json.ToString()); OnSearchFriendResult = (res) => { onResult(res); }; }
public void AuthenticateDeviceId(string deviceId, Action <User, Result> onResult) { JSONObject json = new JSONObject(); json.Add("type", AuthenticateType.deviceId.ToString()); json.Add("deviceId", deviceId); json.Add("location", curTimeZone.StandardName.Replace(" Standard Time", "")); json.Add("timezone_utc_offset", currentOffset.ToString()); _socket.Emit(authenticateEvent, json.ToString()); OnAuthenticateDeviceId = (user, result) => { onResult(user, result); }; }
public void SendMessageToId(string receiverUserId, string text, Action <Result> onResult) { JSONObject json = new JSONObject(); json.Add("type", CommunicationType.toId.ToString()); json.Add("receiverUserId", receiverUserId); json.Add("text", text); json.Add("token", Client.Token); _socket.Emit(communicationEvent, json.ToString()); OnMessageToIdResult = (res) => { onResult(res); }; }
/// <param name="roomCapacity">the max capacity of that room.</param> /// <param name="requestType">request normal game.</param> /// <param name="requestTeamNumber">the number of teams </param> /// <param name="matchMode">The mode of Match</param> /// <param name="onResult">the result of match request.</param> public void RequestMatch(int roomCapacity, int requestTeamNumber, string requestType, string matchMode, Action <Result> onResult) { // request match without playmate for normal game if (requestType == "level" || requestType == "rank") { Result result = new Result(); result.Type = "error"; result.Message = "For requesting level or rank match use range parameter"; onResult(result); return; } Math.DivRem(roomCapacity, requestTeamNumber, out var divideRemaining); if (divideRemaining != 0) { Result result = new Result(); result.Type = "error"; result.Message = "Divide the room capacity by the number of teams should be equal to zero"; onResult(result); return; } JSONObject json = new JSONObject(); json.Add("type", MatchTypes.request.ToString()); json.Add("roomCapacity", roomCapacity); json.Add("requestType", requestType); json.Add("requestTeamNumber", requestTeamNumber); json.Add("matchMode", matchMode); json.Add("token", Client.Token); _socket.Emit(matchmakerEvent, json.ToString()); OnRequestMatchResult = (res) => { onResult(res); }; }