/// <summary> /// Adds a stream event /// </summary> /// <remarks> /// Service Name - PlaybackStream /// Service Operation - AddEvent /// </remarks> /// <param name="in_playbackStreamId"> /// Identifies the stream to read /// </param> /// <param name="in_eventData"> /// Describes the event /// </param> /// <param name="in_summary"> /// Current summary data as of this event /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status": 200, /// "data": null /// } /// </returns> public void AddEvent( string in_playbackStreamId, string in_eventData, string in_summary, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.PlaybackStreamServicePlaybackStreamId.Value] = in_playbackStreamId; if (Util.IsOptionalParameterValid(in_eventData)) { Dictionary<string, object> jsonEventData = JsonReader.Deserialize<Dictionary<string, object>> (in_eventData); data[OperationParam.PlaybackStreamServiceEventData.Value] = jsonEventData; } if (Util.IsOptionalParameterValid(in_summary)) { Dictionary<string, object> jsonSummary = JsonReader.Deserialize<Dictionary<string, object>> (in_summary); data[OperationParam.PlaybackStreamServiceSummary.Value] = jsonSummary; } ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.PlaybackStream, ServiceOperation.AddEvent, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Method will award the achievements specified. On success, this will /// call AwardThirdPartyAchievement to hook into the client-side Achievement /// service (ie GameCentre, Facebook etc). /// </summary> /// <remarks> /// Service Name - Gamification /// Service Operation - AwardAchievements /// </remarks> /// <param name="in_achievementIds"> /// A comma separated list of achievement ids to award /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status":200, /// "data":null /// } /// </returns> public void AwardAchievements( string in_achievementIds, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { string[] ids = in_achievementIds.Split(new char[] { ',' }); string achievementsStr = "["; for (int i = 0, isize = ids.Length; i < isize; ++i) { achievementsStr += (i == 0 ? "\"" : ",\""); achievementsStr += ids[i]; achievementsStr += "\""; } achievementsStr += "]"; string[] achievementData = JsonReader.Deserialize<string[]>(achievementsStr); Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.GamificationServiceAchievementsName.Value] = achievementData; SuccessCallback successCallbacks = (SuccessCallback)AchievementAwardedSuccessCallback; if (in_success != null) { successCallbacks += in_success; } ServerCallback callback = BrainCloudClient.CreateServerCallback(successCallbacks, in_failure); ServerCall sc = new ServerCall(ServiceName.Gamification, ServiceOperation.AwardAchievements, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Registers the given device token with the server to enable this device /// to receive push notifications. /// </param> /// <param name="in_token"> /// The platform-dependant device token needed for push notifications. /// </param> /// <param name="in_success"> /// The success callback /// </param> /// <param name="in_failure"> /// The failure callback /// </param> /// <param name="in_cbObject"> /// The callback object /// </param> /// <returns> JSON describing the new value of the statistics and any rewards that were triggered: /// { /// "status":200, /// "data":null /// } /// </returns> public bool RegisterPushNotificationDeviceToken( byte[] in_token, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { if (in_token != null || in_token.Length < 1) { byte[] token = in_token; // send token to a provider // default to iOS // TODO: implement other device types string deviceType = OperationParam.DeviceRegistrationTypeIos.Value; if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.Android) { deviceType = OperationParam.DeviceRegistrationTypeAndroid.Value; } string hexToken = System.BitConverter.ToString(token).Replace("-","").ToLower(); return RegisterPushNotificationDeviceToken(deviceType, hexToken, in_success, in_failure, in_cbObject); } // there was an error else { return false; } }
/// <summary> /// Registers the given device token with the server to enable this device /// to receive push notifications. /// </param> /// <param name="in_token"> /// The platform-dependant device token needed for push notifications. /// </param> /// <param name="in_success"> /// The success callback /// </param> /// <param name="in_failure"> /// The failure callback /// </param> /// <param name="in_cbObject"> /// The callback object /// </param> /// <returns> JSON describing the new value of the statistics and any rewards that were triggered: /// { /// "status":200, /// "data":null /// } /// </returns> public bool RegisterPushNotificationDeviceToken( byte[] in_token, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { if (in_token != null || in_token.Length < 1) { byte[] token = in_token; Platform platform = Platform.FromUnityRuntime(); string hexToken = System.BitConverter.ToString(token).Replace("-","").ToLower(); RegisterPushNotificationDeviceToken(platform, hexToken, in_success, in_failure, in_cbObject); return true; } // there was an error else { return false; } }
/// <summary> /// Sends an event to the designated player id with the attached json data. /// Any events that have been sent to a player will show up in their /// incoming event mailbox. If the in_recordLocally flag is set to true, /// a copy of this event (with the exact same event id) will be stored /// in the sending player's "sent" event mailbox. /// /// Note that the list of sent and incoming events for a player is returned /// in the "ReadPlayerState" call (in the BrainCloudPlayer module). /// </summary> /// <remarks> /// Service Name - Event /// Service Operation - Send /// </remarks> /// <param name="in_toPlayerId"> /// The id of the player who is being sent the event /// </param> /// <param name="in_eventType"> /// The user-defined type of the event. /// </param> /// <param name="in_jsonEventData"> /// The user-defined data for this event encoded in JSON. /// </param> /// <param name="in_recordLocally"> /// If true, a copy of this event will be saved in the /// user's sent events mailbox. /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback includes the server generated /// event id and is as follows: /// { /// "status":200, /// "data":{ /// "eventId":3824 /// } /// } /// </returns> public void SendEvent( string in_toPlayerId, string in_eventType, string in_jsonEventData, bool in_recordLocally, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.EventServiceSendToId.Value] = in_toPlayerId; data[OperationParam.EventServiceSendEventType.Value] = in_eventType; if (Util.IsOptionalParameterValid(in_jsonEventData)) { Dictionary<string, object> eventData = JsonReader.Deserialize<Dictionary<string, object>> (in_jsonEventData); data[OperationParam.EventServiceSendEventData.Value] = eventData; } data[OperationParam.EventServiceSendRecordLocally.Value] = in_recordLocally; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Event, ServiceOperation.Send, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Merge the profile associated with the provided Facebook credentials with the /// current profile. /// </summary> /// <remarks> /// Service Name - Identity /// Service Operation - Merge /// </remarks> /// <param name="externalId"> /// The facebook id of the user /// </param> /// <param name="authenticationToken"> /// The validated token from the Facebook SDK /// (that will be further validated when sent to the bC service) /// </param> /// <param name="in_success"> /// The method to call in event of successful login /// </param> /// <param name="in_failure"> /// The method to call in the event of an error during authentication /// </param> public void MergeFacebookIdentity( string in_externalId, string in_authenticationToken, SuccessCallback in_success, FailureCallback in_failure) { this.MergeIdentity(in_externalId, in_authenticationToken, OperationParam.AuthenticateServiceAuthenticateAuthFacebook.Value, in_success, in_failure); }
public BaseRequest (String method, String url, SuccessCallback successCallback, ErrorCallback errorCallback):base(method, url) { this.completedCallback = delegate(Request request) { onCompleteCallback(request); };; this.successCallback = successCallback; this.errorCallback = errorCallback; form = AddParams(); }
/// <summary> /// Attach a Email and Password identity to the current profile. /// </summary> /// <remarks> /// Service Name - Identity /// Service Operation - Attach /// </remarks> /// <param name="in_email"> /// The player's e-mail address /// </param> /// <param name="in_password"> /// The player's password /// </param> /// <param name="in_success"> /// The method to call in event of successful login /// </param> /// <param name="in_failure"> /// The method to call in the event of an error during authentication /// </param> /// <returns> /// Errors to watch for: SWITCHING_PROFILES - this means that the email address you provided /// already points to a different profile. You will likely want to offer the player the /// choice to *SWITCH* to that profile, or *MERGE* the profiles. /// /// To switch profiles, call ClearSavedProfileID() and then call AuthenticateEmailPassword(). /// </returns> public void AttachEmailIdentity( string in_email, string in_password, SuccessCallback in_success, FailureCallback in_failure) { this.AttachIdentity(in_email, in_password, OperationParam.AuthenticateServiceAuthenticateAuthEmail.Value, in_success, in_failure); }
public void TokenPreAuth(TokenPaymentViewModel payment, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { var view = _viewLocator.GetTokenPreAuthView(); view.successCallback = success; view.failureCallback = failure; view.tokenPayment = payment; PresentView (navigationController, view); }
public SubmitScoreRequest (String url, String score, SuccessCallback successCallback, ErrorCallback errorCallback): base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public void RegisterCard(PaymentViewModel payment, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { var view = _viewLocator.GetRegisterCardView(); view.successCallback = success; view.failureCallback = failure; view.registerCardModel = payment; PresentView (navigationController, view); }
/// <summary> /// Method returns all of the global statistics. /// </summary> /// <remarks> /// Service Name - GlobalStatistics /// Service Operation - Read /// </remarks> /// <param name="in_success"> /// The success callback /// </param> /// <param name="in_failure"> /// The failure callback /// </param> /// <param name="in_cbObject"> /// The callback object /// </param> /// <returns> JSON describing the global statistics: /// { /// "status":200, /// "data":{ /// "statisticsExceptions":{ /// }, /// "statistics":{ /// "Level02_TimesBeaten":11, /// "Level01_TimesBeaten":1, /// "GameLogins":376, /// "PlayersWhoLikePirateClothing":12 /// } /// } /// } /// </returns> public void ReadAllGlobalStats( SuccessCallback in_success, FailureCallback in_failure, object in_cbObject = null) { ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.GlobalStatistics, ServiceOperation.Read, null, callback); m_brainCloudClientRef.SendRequest(sc); }
public void AuthorizeTwitter( SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Event, ServiceOperation.Send, null, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Returns JSON representing the next experience level for the player. /// </summary> /// <remarks> /// Service Name - PlayerStatistics /// Service Operation - ReadNextXpLevel /// </remarks> /// <param name="in_success"> /// The success callback /// </param> /// <param name="in_failure"> /// The failure callback /// </param> /// <param name="in_cbObject"> /// The callback object /// </param> /// <returns> JSON describing the next experience level for the player. /// { /// "status":200, /// "data":{ /// "xp_level":{ /// "gameId":"com.bitheads.unityexample", /// "numericLevel":2, /// "experience":20, /// "reward":{ /// "globalGameStatistics":null, /// "experiencePoints":null, /// "playerStatistics":null, /// "achievement":null, /// "currencies":{ /// "gems":10, /// "gold":2000 /// } /// }, /// "facebookAction":"", /// "statusTitle":"Jester", /// "key":{ /// "gameId":"com.bitheads.unityexample", /// "numericLevel":2, /// "primaryKey":true /// } /// } /// } /// } /// </returns> public void GetNextExperienceLevel( SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.PlayerStatistics, ServiceOperation.ReadNextXpLevel, null, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Completely deletes the player record and all data fully owned /// by the player. After calling this method, the player will need /// to re-authenticate and create a new profile. /// This is mostly used for debugging/qa. /// </summary> /// <remarks> /// Service Name - PlayerState /// Service Operation - FullReset /// </remarks> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status":200, /// "data":null /// } /// </returns> public void DeletePlayer( SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.PlayerState, ServiceOperation.FullReset, null, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Method reads all the global properties of the game /// </summary> /// <remarks> /// Service Name - GlobalApp /// Service Operation - ReadProperties /// </remarks> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> JSON describing the global properties: /// { /// "status":200, /// "data": { /// "pName": { /// "name": "pName", /// "description": "pValue", /// "value": "pDescription" /// } /// } /// } /// </returns> public void ReadProperties( SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall serverCall = new ServerCall(ServiceName.GlobalApp, ServiceOperation.ReadProperties, null, callback); m_brainCloudClientRef.SendRequest(serverCall); }
public GetHighScoresRequest (String url, String sessionKey, String level, SuccessCallback successCallback, ErrorCallback errorCallback): base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_SESSION_KEY, sessionKey ); hashtable.Add( GameConstants.REQUEST_KEY_LEVEL, level ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public LoginFacebookRequest (String url, string token, SuccessCallback successCallback, ErrorCallback errorCallback) : base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_TOKEN, token ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public GenerateAnonymousAcountRequest (String url, string deviceId, SuccessCallback successCallback, ErrorCallback errorCallback) : base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_DEVICE_ID, deviceId ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public void PreAuth(PaymentViewModel preAuthorisation, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { var view = _viewLocator.GetPreAuthView(); // register card and pre Auth sharing same view so we need to set this property to false view.successCallback = success; view.failureCallback = failure; view.authorisationModel = preAuthorisation; PresentView (navigationController, view); }
public LoginRequest (String url, string userName, string password, SuccessCallback successCallback, ErrorCallback errorCallback) : base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_USER_NAME, userName ); hashtable.Add( GameConstants.REQUEST_KEY_PASSWORD, password ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public SubmitRequestAcceptRequest (String url, string sessionKey, string requestIds, SuccessCallback successCallback, ErrorCallback errorCallback) : base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_SESSION_KEY, sessionKey ); hashtable.Add( GameConstants.REQUEST_KEY_REQUEST_IDS, requestIds ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public GetFriendPlayedGameRequest (String url, String sessionKey, String page, String count, SuccessCallback successCallback, ErrorCallback errorCallback): base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_SESSION_KEY, sessionKey ); hashtable.Add( GameConstants.REQUEST_KEY_PAGE, page ); hashtable.Add( GameConstants.REQUEST_KEY_COUNT, count ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public GetInviteFriendRequest (String url, String sessionKey, String limit, String next, SuccessCallback successCallback, ErrorCallback errorCallback): base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_SESSION_KEY, sessionKey ); hashtable.Add( GameConstants.REQUEST_KEY_LIMIT, limit ); hashtable.Add( GameConstants.REQUEST_KEY_NEXT, next ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public UpdateAcountInfoRequest (String url, string sessionKey, string displayName, string avatar, SuccessCallback successCallback, ErrorCallback errorCallback) : base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_SESSION_KEY, sessionKey ); hashtable.Add( GameConstants.REQUEST_KEY_DISPLAY_NAME, displayName ); hashtable.Add( GameConstants.REQUEST_KEY_AVATAR, avatar ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
public void TokenPreAuth(TokenPaymentViewModel payment, SuccessCallback success, FailureCallback failure, UINavigationController navigationController) { try { _paymentService.MakeTokenPreAuthorisation(payment).ContinueWith(reponse => HandResponse(success, failure, reponse)); } catch (Exception ex) { // Failure HandleFailure (failure,ex); } }
public ShareStoryRequest (String url, string uid, string type, string data, SuccessCallback successCallback, ErrorCallback errorCallback) : base(Method.POST, url, successCallback, errorCallback) { Hashtable hashtable = new Hashtable (); hashtable.Add( GameConstants.REQUEST_KEY_UID, uid ); hashtable.Add( GameConstants.REQUEST_KEY_TYPE, type ); hashtable.Add( GameConstants.RESPONE_KEY_DATA, data ); string json = Json.Serialize(hashtable ); this.form.AddField( GameConstants.REQUEST_KEY_PARAMS, Encryption.Encrypt(json) ); this.AddWWWForm(this.form); }
/// <summary> /// Gets the player's currency for the given currency type /// or all currency types if null passed in. /// </summary> /// <remarks> /// Service Name - Product /// Service Operation - GetPlayerVC /// </remarks> /// <param name="in_currencyType"> /// The currency type to retrieve or null /// if all currency types are being requested. /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status":200, /// "data": { /// "updatedAt": 1395693676208, /// "currencyMap": { /// "gold": { /// "purchased": 0, /// "balance": 0, /// "consumed": 0, /// "awarded": 0 /// } /// }, /// "playerId": "6ea79853-4025-4159-8014-60a6f17ac4e6", /// "createdAt": 1395693676208 /// } /// } /// </returns> public void GetCurrency( string in_currencyType, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ProductServiceGetPlayerVCId.Value] = in_currencyType; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.GetPlayerVC, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Decrements player rating /// </summary> /// <remarks> /// Service Name - MatchMaking /// Service Operation - DecrementPlayerRating /// </remarks> /// <param name="in_decrement"> /// The decrement amount /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status": 200, /// "data": null /// } /// </returns> public void DecrementPlayerRating( long in_decrement, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.MatchMakingServicePlayerRating.Value] = in_decrement; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.MatchMaking, ServiceOperation.DecrementPlayerRating, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Cancels a match /// </summary> /// <remarks> /// Service Name - OneWayMatch /// Service Operation - CancelMatch /// </remarks> /// <param name="in_playbackStreamId"> /// The playback stream id returned in the start match /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status": 200, /// "data": null /// } /// </returns> public void CancelMatch( string in_playbackStreamId, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.OfflineMatchServicePlaybackStreamId.Value] = in_playbackStreamId; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.OneWayMatch, ServiceOperation.CancelMatch, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Updates the options of the registered room /// </summary> public void SaveOptions(int roomId, RoomOptions options, SuccessCallback callback, IClientSocket connection) { if (!connection.IsConnected) { callback.Invoke(false, "Not connected"); return; } var changePacket = new SaveRoomOptionsPacket { Options = options, RoomId = roomId }; connection.SendMessage((short)MsfOpCodes.SaveRoomOptions, changePacket, (status, response) => { if (status != ResponseStatus.Success) { callback.Invoke(false, response.AsString("Unknown Error")); return; } callback.Invoke(true, null); }); }
/// <summary> /// List user files from the given cloud path /// </summary> /// <param name="cloudPath">File path</param> /// <param name="recurse">Whether to recurse down the path</param> /// <param name="success">The success callback</param> /// <param name="failure">The failure callback</param> /// <param name="cbObject">The callback object</param> public void ListUserFiles( string cloudPath, bool?recurse, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); if (Util.IsOptionalParameterValid(cloudPath)) { data[OperationParam.UploadPath.Value] = cloudPath; } if (recurse.HasValue) { data[OperationParam.UploadRecurse.Value] = recurse.Value; } ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.File, ServiceOperation.ListUserFiles, data, callback); _client.SendRequest(sc); }
private void SendRichPushNotification( string toProfileId, int notificationTemplateId, string substitutionJson, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.PushNotificationSendParamToPlayerId.Value] = toProfileId; data[OperationParam.PushNotificationSendParamNotificationTemplateId.Value] = notificationTemplateId; if (Util.IsOptionalParameterValid(substitutionJson)) { data[OperationParam.PushNotificationSendParamSubstitutions.Value] = JsonReader.Deserialize <Dictionary <string, object> >(substitutionJson); } ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.PushNotification, ServiceOperation.SendRich, data, callback); _client.SendRequest(sc); }
/// <summary> /// Like findLobby, but explicitely geared toward creating new lobbies /// </summary> /// /// otherUserCxIds support coming soon! /// public void CreateLobby(string in_roomType, int in_rating, bool in_isReady, Dictionary <string, object> in_extraJson, string in_teamCode, Dictionary <string, object> in_settings, string[] in_otherUserCxIds = null, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.LobbyRoomType.Value] = in_roomType; data[OperationParam.LobbyRating.Value] = in_rating; data[OperationParam.LobbySettings.Value] = in_settings; data[OperationParam.LobbyIsReady.Value] = in_isReady; if (in_otherUserCxIds != null) { data[OperationParam.LobbyOtherUserCxIds.Value] = in_otherUserCxIds; } data[OperationParam.LobbyExtraJson.Value] = in_extraJson; data[OperationParam.LobbyTeamCode.Value] = in_teamCode; ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.Lobby, ServiceOperation.CreateLobby, data, callback); m_clientRef.SendRequest(sc); }
/// <summary> /// Method returns a view of global leaderboard results that centers on the current player. /// /// Leaderboards entries contain the player's score and optionally, some user-defined /// data associated with the score. /// </summary> /// <remarks> /// Service Name - SocialLeaderboard /// Service Operation - GetGlobalLeaderboardView /// </remarks> /// <param name="in_leaderboardId"> /// The id of the leaderboard to retrieve. /// </param> /// <param name="in_sort"> /// Sort key Sort order of page. /// </param> /// <param name="in_beforeCount"> /// The count of number of players before the current player to include. /// </param> /// <param name="in_afterCount"> /// The count of number of players after the current player to include. /// </param> /// <param name="in_includeLeaderboardSize"> /// Whether to return the leaderboard size /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> JSON string representing the entries in the leaderboard. /// Note that the friend summary data is returned for each record /// in the leaderboard. /// /// { /// "status": 200, /// "data": { /// "leaderboardId": "abc", /// "moreBefore": false, /// "timeBeforeReset": 48085996, /// "leaderboard": [ /// { /// "playerId": "8c86f306-73ea-4536-9c92-aba086064d2c", /// "score": 10, /// "data": { /// "nickname": "batman" /// }, /// "createdAt": 1433863814394, /// "updatedAt": 1433863814394, /// "index": 0, /// "rank": 1, /// "name": "", /// "summaryFriendData": { /// "xp": 12, /// "favColour": "red" /// } /// }, /// { /// "playerId": "ab21c0af-9d3e-4a81-b3c8-ddc1fb77d9a1", /// "score": 8, /// "data": { /// "nickname": "robin" /// }, /// "createdAt": 1433864253221, /// "updatedAt": 1433864253221, /// "index": 1, /// "rank": 2, /// "name": "", /// "summaryFriendData": null /// } /// ], /// "server_time": 1433864314004, /// "moreAfter": false /// } /// } /// </returns> public void GetGlobalLeaderboardView( string in_leaderboardId, SortOrder in_sort, int in_beforeCount, int in_afterCount, bool in_includeLeaderboardSize, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = in_leaderboardId; data[OperationParam.SocialLeaderboardServiceSort.Value] = SortOrderToString(in_sort); data[OperationParam.SocialLeaderboardServiceBeforeCount.Value] = in_beforeCount; data[OperationParam.SocialLeaderboardServiceAfterCount.Value] = in_afterCount; data[OperationParam.SocialLeaderboardServiceIncludeLeaderboardSize.Value] = in_includeLeaderboardSize; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.SocialLeaderboard, ServiceOperation.GetGlobalLeaderboardView, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Post the players score to the given social leaderboard. /// You can optionally send a user-defined json string of data /// with the posted score. This string could include information /// relevant to the posted score. /// /// Note that the behaviour of posting a score can be modified in /// the brainCloud portal. By default, the server will only keep /// the player's best score. /// </summary> /// <remarks> /// Service Name - SocialLeaderboard /// Service Operation - PostScore /// </remarks> /// <param name="in_leaderboardId"> /// The leaderboard to post to /// </param> /// <param name="in_score"> /// The score to post /// </param> /// <param name="in_data"> /// Optional user-defined data to post with the score /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status":200, /// "data": null /// } /// </returns> public void PostScoreToLeaderboard( string in_leaderboardId, long in_score, string in_jsonData, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = in_leaderboardId; data[OperationParam.SocialLeaderboardServiceScore.Value] = in_score; if (Util.IsOptionalParameterValid(in_jsonData)) { Dictionary <string, object> customData = JsonReader.Deserialize <Dictionary <string, object> >(in_jsonData); data[OperationParam.SocialLeaderboardServiceData.Value] = customData; } ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.SocialLeaderboard, ServiceOperation.PostScore, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// For sharded custom collection entities. Sets the specified fields within custom entity data on the server, enforcing ownership/ACL permissions. /// </summary> /// <param name="entityType"> /// The entity type as defined by the user /// </param> /// <param name="entityId"></param> /// <param name="version"></param> /// <param name="fieldsJson"></param> /// <param name="shardKeyJson"> /// The shard key field(s) and value(s), as JSON, applicable to the entity being updated. /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void UpdateEntityFieldsSharded( string entityType, string entityId, int version, string fieldsJson, string shardKeyJson, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.CustomEntityServiceEntityType.Value] = entityType; data[OperationParam.CustomEntityServiceEntityId.Value] = entityId; data[OperationParam.CustomEntityServiceVersion.Value] = version; data[OperationParam.CustomEntityServiceFieldsJson.Value] = JsonReader.Deserialize <Dictionary <string, object> >(fieldsJson);; data[OperationParam.CustomEntityServiceShardKeyJson.Value] = JsonReader.Deserialize <Dictionary <string, object> >(shardKeyJson); ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.CustomEntity, ServiceOperation.UpdateCustomEntityFieldsShards, data, callback); _client.SendRequest(sc); }
public void GetEntityPage( string entityType, int rowsPerPage, string searchJson, string sortJson, bool doCount, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.CustomEntityServiceEntityType.Value] = entityType; data[OperationParam.CustomEntityServiceRowsPerPage.Value] = rowsPerPage; data[OperationParam.CustomEntityServiceSearchJson.Value] = JsonReader.Deserialize <Dictionary <string, object> >(searchJson); data[OperationParam.CustomEntityServiceSortJson.Value] = JsonReader.Deserialize <Dictionary <string, object> >(sortJson); data[OperationParam.CustomEntityServiceDoCount.Value] = doCount; ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.CustomEntity, ServiceOperation.GetCustomEntityPage, data, callback); _client.SendRequest(sc); }
/// </summary> ///Updates the singleton owned by the user for the specified custom entity type on the server, creating the singleton if it does not exist. This operation results in the owned singleton's data being completely replaced by the passed in JSON object. /// <remarks> /// Service Name - CustomEntity /// Service Operation -UpdateSingleton /// </remarks> /// <param name="entityType"> /// </param> /// <param name="entityId"> /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void UpdateSingleton( string entityType, int version, string dataJson, string acl, string timeToLive, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.CustomEntityServiceEntityType.Value] = entityType; data[OperationParam.CustomEntityServiceVersion.Value] = version; data[OperationParam.CustomEntityServiceDataJson.Value] = JsonReader.Deserialize <Dictionary <string, object> >(dataJson); data[OperationParam.CustomEntityServiceAcl.Value] = JsonReader.Deserialize <Dictionary <string, object> >(acl); data[OperationParam.CustomEntityServiceTimeToLive.Value] = timeToLive; ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.CustomEntity, ServiceOperation.UpdateSingleton, data, callback); _client.SendRequest(sc); }
/// <summary> /// Allows a quantity of a specified user item to be sold. ///If any quantity of the user item remains, ///it will be returned, potentially with the associated ///itemDef (with language fields limited to the current ///or default language), along with the currency refunded ///and currency balances. /// </summary> /// <remarks> /// Service Name - UserInventoryManagement /// Service Operation - SellUserItem /// </remarks> /// <param name="itemId"> /// </param> /// <param name="version"> /// </param> /// <param name="quantity"> /// </param> /// <param name="shopId"> /// </param> /// <param name="includeDef"> /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void SellUserItem( string itemId, int version, int quantity, string shopId, bool includeDef, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.UserItemsServiceItemId.Value] = itemId; data[OperationParam.UserItemsServiceVersion.Value] = version; data[OperationParam.UserItemsServiceQuantity.Value] = quantity; data[OperationParam.UserItemsServiceShopId.Value] = shopId; data[OperationParam.UserItemsServiceIncludeDef.Value] = includeDef; ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.UserItems, ServiceOperation.SellUserItem, data, callback); _client.SendRequest(sc); }
/// <summary> /// Sends a notification to a "group" of user based on a brainCloud portal configured notification template. /// Includes JSON defining the substitution params to use with the template. /// See the Portal documentation for more info. /// </param> /// <param name="groupId"> /// Target group /// </param> /// <param name="notificationTemplateId"> /// Id of the notification template /// </param> /// <param name="substitutionsJson"> /// JSON defining the substitution params to use with the template /// </param> /// <param name="success"> /// The success callback /// </param> /// <param name="failure"> /// The failure callback /// </param> /// <param name="cbObject"> /// The callback object /// </param> public void SendTemplatedPushNotificationToGroup( string groupId, int notificationTemplateId, string substitutionsJson, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.GroupId.Value] = groupId; data[OperationParam.PushNotificationSendParamNotificationTemplateId.Value] = notificationTemplateId; if (Util.IsOptionalParameterValid(substitutionsJson)) { data[OperationParam.PushNotificationSendParamSubstitutions.Value] = JsonReader.Deserialize <Dictionary <string, object> >(substitutionsJson); } ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.PushNotification, ServiceOperation.SendTemplatedToGroup, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Finds a lobby matching the specified parameters WITH PING DATA. GetRegionsForLobbies and PingRegions must be successfully responded to /// prior to calling. /// </summary> /// public void FindLobbyWithPingData(string in_roomType, int in_rating, int in_maxSteps, Dictionary <string, object> in_algo, Dictionary <string, object> in_filterJson, int in_timeoutSecs, bool in_isReady, Dictionary <string, object> in_extraJson, string in_teamCode, string[] in_otherUserCxIds = null, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.LobbyRoomType.Value] = in_roomType; data[OperationParam.LobbyRating.Value] = in_rating; data[OperationParam.LobbyMaxSteps.Value] = in_maxSteps; data[OperationParam.LobbyAlgorithm.Value] = in_algo; data[OperationParam.LobbyFilterJson.Value] = in_filterJson; data[OperationParam.LobbyTimeoutSeconds.Value] = in_timeoutSecs; data[OperationParam.LobbyIsReady.Value] = in_isReady; if (in_otherUserCxIds != null) { data[OperationParam.LobbyOtherUserCxIds.Value] = in_otherUserCxIds; } data[OperationParam.LobbyExtraJson.Value] = in_extraJson; data[OperationParam.LobbyTeamCode.Value] = in_teamCode; attachPingDataAndSend(data, ServiceOperation.FindLobbyWithPingData, success, failure, cbObject); }
/// <summary> /// Partial increment of shared entity data field items. Partial set of items incremented as specified. /// </summary> /// <remarks> /// Service Name - entity /// Service Operation - INCREMENT_SHARED_USER_ENTITY_DATA /// </remarks> /// <param name="entityId">The entity to increment</param> /// <param name="targetProfileId">Profile ID of the entity owner</param> /// <param name="jsonData">The subset of data to increment</param> /// <param name="success">The success callback</param> /// <param name="failure">The failure callback</param> /// <param name="cbObject">The callback object</param> public void IncrementSharedUserEntityData( string entityId, string targetProfileId, string jsonData, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { var data = new Dictionary <string, object>(); data[OperationParam.EntityServiceEntityId.Value] = entityId; data[OperationParam.EntityServiceTargetPlayerId.Value] = targetProfileId; if (Util.IsOptionalParameterValid(jsonData)) { var where = JsonReader.Deserialize <Dictionary <string, object> >(jsonData); data[OperationParam.EntityServiceData.Value] = where; } var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); var serverCall = new ServerCall(ServiceName.Entity, ServiceOperation.IncrementSharedUserEntityData, data, callback); _client.SendRequest(serverCall); }
/// <summary> /// Gifts item to the specified player. /// </summary> /// <remarks> /// Service Name - UserInventoryManagement /// Service Operation - GetUserItem /// </remarks> /// <param name="profileId"> /// </param> /// <param name="itemId"> /// </param> /// <param name="version"> /// </param> /// <param name="quantity"> /// </param> /// <param name="immediate"> /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void GiveUserItemTo( String profileId, String itemId, int version, int quantity, bool immediate, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.UserItemsServiceProfileId.Value] = profileId; data[OperationParam.UserItemsServiceItemId.Value] = itemId; data[OperationParam.UserItemsServiceVersion.Value] = version; data[OperationParam.UserItemsServiceQuantity.Value] = quantity; data[OperationParam.UserItemsServiceImmediate.Value] = immediate; ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.UserItems, ServiceOperation.GiveUserItemTo, data, callback); _client.SendRequest(sc); }
/// <summary> /// Post the players score to the given social leaderboard. /// You can optionally send a user-defined json string of data /// with the posted score. This string could include information /// relevant to the posted score. /// /// Note that the behaviour of posting a score can be modified in /// the brainCloud portal. By default, the server will only keep /// the player's best score. /// </summary> /// <remarks> /// Service Name - leaderboard /// Service Operation - PostScore /// </remarks> /// <param name="leaderboardId"> /// The leaderboard to post to /// </param> /// <param name="score"> /// The score to post /// </param> /// <param name="data"> /// Optional user-defined data to post with the score /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void PostScoreToLeaderboard( string leaderboardId, long score, string jsonData, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { var data = new Dictionary <string, object>(); data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = leaderboardId; data[OperationParam.SocialLeaderboardServiceScore.Value] = score; if (Util.IsOptionalParameterValid(jsonData)) { var customData = JsonReader.Deserialize <Dictionary <string, object> >(jsonData); data[OperationParam.SocialLeaderboardServiceData.Value] = customData; } var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); var sc = new ServerCall(ServiceName.Leaderboard, ServiceOperation.PostScore, data, callback); _client.SendRequest(sc); }
/// <summary> /// Method returns a page of global leaderboard results. By using a non-current version id, /// the user can retrieve a historical leaderboard. See GetGlobalLeaderboardVersions method /// to retrieve the version id. /// </summary> /// <remarks> /// Service Name - leaderboard /// Service Operation - GetGlobalLeaderboardPage /// </remarks> /// <param name="leaderboardId"> /// The id of the leaderboard to retrieve. /// </param> /// <param name="sort"> /// Sort key Sort order of page. /// </param> /// <param name="startIndex"> /// The index at which to start the page. /// </param> /// <param name="endIndex"> /// The index at which to end the page. /// </param> /// <param name="versionId"> /// The historical version to retrieve. /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void GetGlobalLeaderboardPageByVersion( string leaderboardId, SortOrder sort, int startIndex, int endIndex, int versionId, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { var data = new Dictionary <string, object>(); data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = leaderboardId; data[OperationParam.SocialLeaderboardServiceSort.Value] = sort.ToString(); data[OperationParam.SocialLeaderboardServiceStartIndex.Value] = startIndex; data[OperationParam.SocialLeaderboardServiceEndIndex.Value] = endIndex; data[OperationParam.SocialLeaderboardServiceVersionId.Value] = versionId; var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); var sc = new ServerCall(ServiceName.Leaderboard, ServiceOperation.GetGlobalLeaderboardPage, data, callback); _client.SendRequest(sc); }
/// <summary> /// Retrieve a view of the group leaderboard surrounding the current group /// </summary> /// <remarks> /// Service Name - leaderboard /// Service Operation - GET_GROUP_LEADERBOARD_VIEW /// </remarks> /// <param name="leaderboardId"> /// the id of the leaderboard /// </param> /// <param name="groupId"> /// The groups Id /// </param> /// <param name="sort"> /// The groups Id /// </param> /// <param name="beforeCount"> /// The count of number of players before the current player to include. /// </param> /// <param name="afterCount"> /// The count of number of players after the current player to include. /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void GetGroupLeaderboardView( string leaderboardId, string groupId, SortOrder sort, int beforeCount, int afterCount, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { var data = new Dictionary <string, object>(); data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = leaderboardId; data[OperationParam.SocialLeaderboardServiceGroupId.Value] = groupId; data[OperationParam.SocialLeaderboardServiceSort.Value] = sort.ToString(); data[OperationParam.SocialLeaderboardServiceBeforeCount.Value] = beforeCount; data[OperationParam.SocialLeaderboardServiceAfterCount.Value] = afterCount; var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); var sc = new ServerCall(ServiceName.Leaderboard, ServiceOperation.GetGroupLeaderboardView, data, callback); _client.SendRequest(sc); }
/// <summary> /// Add a member to the group. /// </summary> /// <remarks> /// Service Name - group /// Service Operation - ADD_GROUP_MEMBER /// </remarks> /// <param name="groupId"> /// ID of the group. /// </param> /// <param name="profileId"> /// Profile ID of the member being added. /// </param> /// <param name="role"> /// Role of the member being added. /// </param> /// <param name="jsonAttributes"> /// Attributes of the member being added. /// </param> /// <param name="success">The success callback</param> /// <param name="failure">The failure callback</param> /// <param name="cbObject">The callback object</param> public void AddGroupMember( string groupId, string profileId, Role role, string jsonAttributes, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.GroupId.Value] = groupId; data[OperationParam.GroupProfileId.Value] = profileId; data[OperationParam.GroupRole.Value] = role.ToString(); if (Util.IsOptionalParameterValid(jsonAttributes)) { Dictionary <string, object> customData = JsonReader.Deserialize <Dictionary <string, object> >(jsonAttributes); data[OperationParam.GroupAttributes.Value] = customData; } SendRequest(ServiceOperation.AddGroupMember, success, failure, cbObject, data); }
/// <summary> /// Returns an array of all classifiers to the callback function. /// </summary> /// <param name="successCallback">The success callback.</param> /// <param name="failCallback">The fail callback.</param> /// <returns>Returns true if the request is submitted.</returns> public bool GetClassifiers(SuccessCallback <Classifiers> successCallback, FailCallback failCallback, Dictionary <string, object> customData = null) { if (successCallback == null) { throw new ArgumentNullException("successCallback"); } if (failCallback == null) { throw new ArgumentNullException("failCallback"); } RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v1/classifiers"); if (connector == null) { return(false); } GetClassifiersReq req = new GetClassifiersReq(); req.SuccessCallback = successCallback; req.FailCallback = failCallback; req.HttpMethod = UnityWebRequest.kHttpVerbGET; req.DisableSslVerification = DisableSslVerification; req.CustomData = customData == null ? new Dictionary <string, object>() : customData; if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) { foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> ) { req.Headers.Add(kvp.Key, kvp.Value); } } req.OnResponse = OnGetClassifiersResp; req.Headers["X-IBMCloud-SDK-Analytics"] = "service_name=natural_language_classifier;service_version=v1;operation_id=GetClassifiers"; return(connector.Send(req)); }
/// <summary> /// Sends a request to server, retrieves all profile values, and applies them to a provided /// profile /// </summary> public void FillProfileValues(ObservableServerProfile profile, SuccessCallback callback, IClientSocket connection) { if (!connection.IsConnected) { callback.Invoke(false, "Not connected"); return; } connection.SendMessage((short)MstMessageCodes.ServerProfileRequest, profile.UserId, (status, response) => { if (status != ResponseStatus.Success) { callback.Invoke(false, response.AsString("Unknown error")); return; } // Use the bytes received, to replicate the profile profile.FromBytes(response.AsBytes()); // Clear all updates if exist profile.ClearUpdates(); // Add profile to list profilesList[profile.UserId] = profile; // Register listener for modified profile.OnModifiedInServerEvent += serverProfile => { OnProfileModified(profile, connection); }; // Register to dispose event profile.OnDisposedEvent += OnProfileDisposed; callback.Invoke(true, null); }); }
/// <summary> /// Post the players score to the given social leaderboard with a rotation type of DAYS. /// Pass leaderboard config data to dynamically create if necessary. /// You can optionally send a user-defined json string of data /// with the posted score. This string could include information /// relevant to the posted score. /// </summary> /// <remarks> /// Service Name - leaderboard /// Service Operation - PostScoreDynamic /// </remarks> /// <param name="leaderboardId"> /// The leaderboard to post to /// </param> /// <param name="score"> /// The score to post /// </param> /// <param name="data"> /// Optional user-defined data to post with the score /// </param> /// <param name="leaderboardType"> /// leaderboard type /// </param> /// <param name="rotationReset"> /// Date to reset the leaderboard UTC /// </param> /// <param name="retainedCount"> /// How many rotations to keep /// </param> /// <param name="numDaysToRotate"> /// How many days between each rotation /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void PostScoreToDynamicLeaderboardDays( string leaderboardId, long score, string jsonData, SocialLeaderboardType leaderboardType, DateTime?rotationReset, int retainedCount, int numDaysToRotate, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { var data = new Dictionary <string, object>(); data[OperationParam.SocialLeaderboardServiceLeaderboardId.Value] = leaderboardId; data[OperationParam.SocialLeaderboardServiceScore.Value] = score; if (Util.IsOptionalParameterValid(jsonData)) { var customData = JsonReader.Deserialize <Dictionary <string, object> >(jsonData); data[OperationParam.SocialLeaderboardServiceData.Value] = customData; } data[OperationParam.SocialLeaderboardServiceLeaderboardType.Value] = leaderboardType.ToString(); data[OperationParam.SocialLeaderboardServiceRotationType.Value] = "DAYS"; if (rotationReset.HasValue) { data[OperationParam.SocialLeaderboardServiceRotationResetTime.Value] = Util.DateTimeToUnixTimestamp(rotationReset.Value); } data[OperationParam.SocialLeaderboardServiceRetainedCount.Value] = retainedCount; data[OperationParam.NumDaysToRotate.Value] = numDaysToRotate; var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); var sc = new ServerCall(ServiceName.Leaderboard, ServiceOperation.PostScoreDynamic, data, callback); _client.SendRequest(sc); }
/// <summary> /// Create a session. /// /// Create a new session. A session is used to send user input to a skill and receive responses. It also /// maintains the state of the conversation. /// </summary> /// <param name="successCallback">The function that is called when the operation is successful.</param> /// <param name="failCallback">The function that is called when the operation fails.</param> /// <param name="assistantId">Unique identifier of the assistant. You can find the assistant ID of an assistant /// on the **Assistants** tab of the Watson Assistant tool. For information about creating assistants, see the /// [documentation](https://console.bluemix.net/docs/services/assistant/create-assistant.html#creating-assistants). /// /// **Note:** Currently, the v2 API does not support creating assistants.</param> /// <returns><see cref="SessionResponse" />SessionResponse</returns> /// <param name="customData">A Dictionary<string, object> of data that will be passed to the callback. The raw /// json output from the REST call will be passed in this object as the value of the 'json' /// key.</string></param> public bool CreateSession(SuccessCallback <SessionResponse> successCallback, FailCallback failCallback, String assistantId, Dictionary <string, object> customData = null) { if (successCallback == null) { throw new ArgumentNullException("successCallback"); } if (failCallback == null) { throw new ArgumentNullException("failCallback"); } CreateSessionRequestObj req = new CreateSessionRequestObj(); req.SuccessCallback = successCallback; req.FailCallback = failCallback; req.CustomData = customData == null ? new Dictionary <string, object>() : customData; if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) { foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> ) { req.Headers.Add(kvp.Key, kvp.Value); } } req.Headers["Content-Type"] = "application/json"; req.Parameters["version"] = VersionDate; req.OnResponse = OnCreateSessionResponse; req.Post = true; RESTConnector connector = RESTConnector.GetConnector(Credentials, string.Format("/v2/assistants/{0}/sessions", assistantId)); if (connector == null) { return(false); } return(connector.Send(req)); }
/// <summary> /// Lists available models for Relations and Entities features, including Watson Knowledge Studio /// custom models that you have created and linked to your Natural Language Understanding service. /// </summary> /// <param name="successCallback">The success callback.</param> /// <param name="failCallback">The fail callback.</param> /// <param name="customData">Optional custom data.</param> /// <returns>True if the call succeeds, false if the call is unsuccessful.</returns> public bool GetModels(SuccessCallback <ListModelsResults> successCallback, FailCallback failCallback, Dictionary <string, object> customData = null) { if (successCallback == null) { throw new ArgumentNullException("successCallback"); } if (failCallback == null) { throw new ArgumentNullException("failCallback"); } GetModelsRequest req = new GetModelsRequest(); req.SuccessCallback = successCallback; req.FailCallback = failCallback; req.HttpMethod = UnityWebRequest.kHttpVerbGET; req.DisableSslVerification = DisableSslVerification; req.CustomData = customData == null ? new Dictionary <string, object>() : customData; if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) { foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> ) { req.Headers.Add(kvp.Key, kvp.Value); } } req.Parameters["version"] = NaturalLanguageUnderstandingVersion.Version; req.OnResponse = OnGetModelsResponse; RESTConnector connector = RESTConnector.GetConnector(Credentials, ModelsEndpoint); if (connector == null) { return(false); } return(connector.Send(req)); }
/// <summary> /// Message the specified workspaceId, input and callback. /// </summary> /// <param name="successCallback">The success callback.</param> /// <param name="failCallback">The fail callback.</param> /// <param name="workspaceID">Workspace identifier.</param> /// <param name="input">Input.</param> /// <param name="customData">Custom data.</param> public bool Message(SuccessCallback <object> successCallback, FailCallback failCallback, string workspaceID, string input, Dictionary <string, object> customData = null) { //if (string.IsNullOrEmpty(workspaceID)) // throw new ArgumentNullException("workspaceId"); if (successCallback == null) { throw new ArgumentNullException("successCallback"); } if (failCallback == null) { throw new ArgumentNullException("failCallback"); } RESTConnector connector = RESTConnector.GetConnector(Credentials, Workspaces); if (connector == null) { return(false); } string reqJson = "{{\"input\": {{\"text\": \"{0}\"}}}}"; string reqString = string.Format(reqJson, input); MessageReq req = new MessageReq(); req.SuccessCallback = successCallback; req.FailCallback = failCallback; req.Headers["Content-Type"] = "application/json"; req.Headers["Accept"] = "application/json"; req.Parameters["version"] = VersionDate; req.Function = "/" + workspaceID + "/message"; req.Send = Encoding.UTF8.GetBytes(reqString); req.OnResponse = MessageResp; req.CustomData = customData == null ? new Dictionary <string, object>() : customData; return(connector.Send(req)); }
/// <summary> /// Finds matchmaking enabled players with additional attributes /// </summary> /// <remarks> /// Service Name - MatchMaking /// Service Operation - FIND_PLAYERS /// </remarks> /// <param name="rangeDelta"> /// The range delta /// </param> /// <param name="numMatches"> /// The maximum number of matches to return /// </param> /// <param name="jsonAttributes"> /// Attributes match criteria /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void FindPlayersWithAttributes( long rangeDelta, long numMatches, string jsonAttributes, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.MatchMakingServiceRangeDelta.Value] = rangeDelta; data[OperationParam.MatchMakingServiceNumMatches.Value] = numMatches; if (Util.IsOptionalParameterValid(jsonAttributes)) { Dictionary <string, object> attribs = JsonReader.Deserialize <Dictionary <string, object> >(jsonAttributes); data[OperationParam.MatchMakingServiceAttributes.Value] = attribs; } ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); ServerCall sc = new ServerCall(ServiceName.MatchMaking, ServiceOperation.FindPlayers, data, callback); _client.SendRequest(sc); }
/// <summary> /// Method updates an existing entity's Acl on the server. /// </summary> /// <remarks> /// Service Name - GlobalEntity /// Service Operation - UpdateAcl /// </remarks> /// <param name="entityId"> /// The entity ID /// </param> /// <param name="version"> /// The version of the entity to update /// </param> /// <param name="jsonEntityAcl"> /// The entity's access control list as json. /// </param> /// <param name="success"> /// The success callback. /// </param> /// <param name="failure"> /// The failure callback. /// </param> /// <param name="cbObject"> /// The user object sent to the callback. /// </param> public void UpdateEntityAcl( string entityId, int version, string jsonEntityAcl, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { var data = new Dictionary <string, object>(); data[OperationParam.GlobalEntityServiceEntityId.Value] = entityId; data[OperationParam.GlobalEntityServiceVersion.Value] = version; if (Util.IsOptionalParameterValid(jsonEntityAcl)) { var acl = JsonReader.Deserialize <Dictionary <string, object> >(jsonEntityAcl); data[OperationParam.GlobalEntityServiceAcl.Value] = acl; } var callback = BrainCloudClient.CreateServerCallback(success, failure, cbObject); var serverCall = new ServerCall(ServiceName.GlobalEntity, ServiceOperation.UpdateAcl, data, callback); _client.SendRequest(serverCall); }
/// <summary> /// This function returns a list to the callback of all identifiable languages. /// </summary> /// <param name="successCallback">The success callback.</param> /// <param name="failCallback">The fail callback.</param> /// <returns>Returns true if the request was submitted.</returns> public bool GetLanguages(SuccessCallback <Languages> successCallback, FailCallback failCallback, Dictionary <string, object> customData = null) { if (successCallback == null) { throw new ArgumentNullException("successCallback"); } if (failCallback == null) { throw new ArgumentNullException("failCallback"); } RESTConnector connector = RESTConnector.GetConnector(Credentials, "/v2/identifiable_languages"); if (connector == null) { return(false); } GetLanguagesReq req = new GetLanguagesReq(); req.SuccessCallback = successCallback; req.FailCallback = failCallback; req.HttpMethod = UnityWebRequest.kHttpVerbGET; req.DisableSslVerification = DisableSslVerification; req.CustomData = customData == null ? new Dictionary <string, object>() : customData; if (req.CustomData.ContainsKey(Constants.String.CUSTOM_REQUEST_HEADERS)) { foreach (KeyValuePair <string, string> kvp in req.CustomData[Constants.String.CUSTOM_REQUEST_HEADERS] as Dictionary <string, string> ) { req.Headers.Add(kvp.Key, kvp.Value); } } req.OnResponse = GetLanguagesResponse; return(connector.Send(req)); }
/// <summary> /// Advanced universalId password reset using templates with expiry /// </summary> /// <remarks> /// Service Name - Authenticate /// Operation - ResetUniversalIdPasswordAdvanced /// </remarks> /// <param name="appId"> /// The app id /// </param> /// <param name="universalId"> /// The email address to send the reset email to /// </param> /// <param name="serviceParams"> /// The parameters to send the email service. See documentation for full list /// http://getbraincloud.com/apidocs/apiref/#capi-mail /// </param> /// <param name="expiryTimeInMin"> /// takes in an Expiry time to determine how long it will stay available /// </param> /// <param name="success"> /// The method to call in event of success /// </param> /// <param name="failure"> /// The method to call in the event of an error /// </param> /// <param name="cbObject"> /// The user supplied callback object /// </param> public void ResetUniversalIdPasswordAdvancedWithExpiry( string universalId, string serviceParams, int tokenTtlInMinutes, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.AuthenticateServiceAuthenticateGameId.Value] = _client.AppId; data[OperationParam.AuthenticateServiceAuthenticateUniversalId.Value] = universalId; var jsonParams = JsonReader.Deserialize <Dictionary <string, object> >(serviceParams); data[OperationParam.AuthenticateServiceAuthenticateServiceParams.Value] = jsonParams; data[OperationParam.AuthenticateServiceAuthenticateTokenTtlInMinutes.Value] = tokenTtlInMinutes; ServerCallback callback = BrainCloudClient.CreateServerCallback(success, failure); ServerCall sc = new ServerCall(ServiceName.Authenticate, ServiceOperation.ResetUniversalIdPasswordAdvancedWithExpiry, data, callback); _client.SendRequest(sc); }
/// <summary> /// Update a member of the group. /// </summary> /// <remarks> /// Service Name - group /// Service Operation - UPDATE_GROUP_MEMBER /// </remarks> /// <param name="groupId"> /// ID of the group. /// </param> /// <param name="profileId"> /// Profile ID of the member being updated. /// </param> /// <param name="role"> /// Role of the member being updated (optional). /// </param> /// <param name="jsonAttributes"> /// Attributes of the member being updated (optional). /// </param> /// <param name="success">The success callback</param> /// <param name="failure">The failure callback</param> /// <param name="cbObject">The callback object</param> public void UpdateGroupMember( string groupId, string profileId, Role?role, string jsonAttributes, SuccessCallback success = null, FailureCallback failure = null, object cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.GroupId.Value] = groupId; data[OperationParam.GroupProfileId.Value] = profileId; if (role.HasValue) { data[OperationParam.GroupRole.Value] = role.Value.ToString(); } if (!string.IsNullOrEmpty(jsonAttributes)) { data[OperationParam.GroupAttributes.Value] = JsonReader.Deserialize(jsonAttributes); } SendRequest(ServiceOperation.UpdateGroupMember, success, failure, cbObject, data); }
/// <summary> /// Updates an event in the player's incoming event mailbox. /// </summary> /// <remarks> /// Service Name - Event /// Service Operation - UpdateEventData /// </remarks> /// <param name="in_fromPlayerId"> /// The id of the player who sent the event /// </param> /// <param name="in_eventId"> /// The event id /// </param> /// <param name="in_jsonEventData"> /// The user-defined data for this event encoded in JSON. /// </param> /// <param name="in_success"> /// The success callback. /// </param> /// <param name="in_failure"> /// The failure callback. /// </param> /// <param name="in_cbObject"> /// The user object sent to the callback. /// </param> /// <returns> The JSON returned in the callback is as follows: /// { /// "status":200, /// "data":null /// } /// </returns> public void UpdateIncomingEventData( string in_fromPlayerId, ulong in_eventId, string in_jsonEventData, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary <string, object> data = new Dictionary <string, object>(); data[OperationParam.EventServiceUpdateEventDataFromId.Value] = in_fromPlayerId; data[OperationParam.EventServiceUpdateEventDataEventId.Value] = in_eventId; if (Util.IsOptionalParameterValid(in_jsonEventData)) { Dictionary <string, object> eventData = JsonReader.Deserialize <Dictionary <string, object> > (in_jsonEventData); data[OperationParam.EventServiceUpdateEventDataData.Value] = eventData; } ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Event, ServiceOperation.UpdateEventData, data, callback); m_brainCloudClientRef.SendRequest(sc); }