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> /// 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 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); }
/// <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); }
/// <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> /// 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> /// Returns a particular entity of a particular friend. /// </summary> /// <remarks> /// Service Name - Friend /// Service Operation - ReadFriendEntity /// </remarks> /// <param name="in_entityId"> /// Id of entity to retrieve. /// </param> /// <param name="in_friendId"> /// Profile Id of friend who owns entity. /// </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 /// </returns> public void ReadFriendEntity( string in_entityId, string in_friendId, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.FriendServiceEntityId.Value] = in_entityId; data[OperationParam.FriendServiceFriendId.Value] = in_friendId; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Friend, ServiceOperation.ReadFriendEntity, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Starts a match /// </summary> /// <remarks> /// Service Name - OneWayMatch /// Service Operation - StartMatch /// </remarks> /// <param name="in_otherPlayerId"> The player to start a match with </param> /// <param name="in_rangeDelta"> The range delta used for the initial match search </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": { /// "playbackStreamId": "d18719db-9d02-2341-b62f-8e2f013369be", /// "initiatingPlayerId": "d175f6ac-9221-4adc-aea4-f25f2426ff62", /// "targetPlayerId": "07a0d23e-996b-4488-90ae-cb438342423a54", /// "status": "STARTED", /// "summary": {}, /// "initialSharedData": { /// "entities": [], /// "statistics": {} /// }, /// "events": [], /// "createdAt": 1437419496282, /// "updatedAt": 1437419496282 /// } /// } /// </returns> public void StartMatch( string in_otherPlayerId, long in_rangeDelta, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.OfflineMatchServicePlayerId.Value] = in_otherPlayerId; data[OperationParam.OfflineMatchServiceRangeDelta.Value] = in_rangeDelta; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.OneWayMatch, ServiceOperation.StartMatch, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Delete an event out of the player's incoming mailbox. /// </summary> /// <remarks> /// Service Name - Event /// Service Operation - DeleteIncoming /// </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_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 DeleteIncomingEvent( string in_fromPlayerId, ulong in_eventId, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.EventServiceDeleteIncomingFromId.Value] = in_fromPlayerId; data[OperationParam.EventServiceDeleteIncomingEventId.Value] = in_eventId; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Event, ServiceOperation.DeleteIncoming, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Retrieves profile information for the specified user. /// </summary> /// <remarks> /// Service Name - Friend /// Service Operation - GetFriendProfileInfo /// </remarks> /// <param name="in_friendId"> /// Profile Id of friend who owns entity. /// </param> /// <param name="in_authenticationType"> /// The authentication type used for this friend id e.g. Facebook /// </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 /// { /// "status":200, /// "data": { /// "playerId" : "17c7ee96-1b73-43d0-8817-cba1953bbf57", /// "playerName" : "Donald Trump", /// "email" : "*****@*****.**", /// "playerSummaryData" : {}, /// } /// } /// </returns> public void GetFriendProfileInfo( string in_friendId, string in_authenticationType, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.FriendServiceFriendId.Value] = in_friendId; data[OperationParam.FriendServiceAuthenticationType.Value] = in_authenticationType; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Friend, ServiceOperation.GetFriendProfileInfo, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Marks the given match as abandoned. /// </summary> /// <remarks> /// Service Name - AsyncMatch /// Service Operation - Abandon /// </remarks> /// <param name="ownerId"> /// Match owner identifier /// </param> /// <param name="matchId"> /// Match identifier /// </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> /// { /// "status": 200, /// "data": {} /// } /// </returns> public void AbandonMatch( string in_ownerId, string in_matchId, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data["ownerId"] = in_ownerId; data["matchId"] = in_matchId; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.AsyncMatch, ServiceOperation.Abandon, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Executes a script on the server. /// </summary> /// <remarks> /// Service Name - Script /// Service Operation - Run /// </remarks> /// <param name="in_scriptName"> /// The name of the script to be run /// </param> /// <param name="in_jsonScriptData"> /// Data to be sent to the script in json format /// </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 //// this value depends on what the script returns /// } /// @see The API documentation site for more details on cloud code /// </returns> public void RunScript( string in_scriptName, string in_jsonScriptData, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ScriptServiceRunScriptName.Value] = in_scriptName; if (Util.IsOptionalParameterValid(in_jsonScriptData)) { Dictionary<string, object> scriptData = JsonReader.Deserialize<Dictionary<string, object>>(in_jsonScriptData); data[OperationParam.ScriptServiceRunScriptData.Value] = scriptData; } ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Script, ServiceOperation.Run, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Sends an array of file details and returns /// the details of any of those files that have changed /// </summary> /// <remarks> /// Service Name - S3Handling /// Service Operation - GetUpdatedFiles /// </remarks> /// <param name="in_category"> /// Category of files on server to compare against /// </param> /// <param name="in_fileDetailsJson"> /// An array of file details /// </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, /// "fileDetails": [ /// { /// "gameId": "12311331", /// "fileId": "3780516b-14f8-4055-8899-8eaab6ac7e82", /// "shortName": "Test Doc", /// "fileName": "testDoc.txt", /// "type": "g", /// "subType": "cust", /// "category": null, /// "fileSize": 4, /// "dateUploaded": 1437154770000, /// "relativeUrl": "/cust/testDoc.txt", /// "absoluteUrl": "http://internal.braincloudservers.com/s3/portal/g/12311331/cust/testDoc.txt", /// "md5Hash": "d41d8cd98f00b204e9800998ecf8427e" /// } /// ] /// } /// </returns> public void GetUpdatedFiles( string in_category, string in_fileDetailsJson, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); if (Util.IsOptionalParameterValid(in_category)) { data[OperationParam.S3HandlingServiceFileCategory.Value] = in_category; } data[OperationParam.S3HandlingServiceFileDetails.Value] = JsonReader.Deserialize<object[]>(in_fileDetailsJson); ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.S3Handling, ServiceOperation.GetUpdatedFiles, data, callback); m_brainCloudClientRef.SendRequest(sc); }
public void Tweet( string in_token, string in_secret, string in_tweet, string in_picture, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.TwitterServiceTweetToken.Value] = in_token; data[OperationParam.TwitterServiceTweetSecret.Value] = in_secret; data[OperationParam.TwitterServiceTweetTweet.Value] = in_tweet; if (Util.IsOptionalParameterValid(in_picture)) { data[OperationParam.TwitterServiceTweetPic.Value] = in_picture; } 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> /// Verify ITunes Receipt. On success, the player will be awarded the /// associated currencies. /// </summary> /// <remarks> /// Service Name - product /// Service Operation - OP_CASH_IN_RECEIPT /// </remarks> /// <param name="in_base64EncReceiptData"> /// Base64 encoded receipt data /// </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": /// { /// "playerCurrency" : { /// "playerId" : "sfhsjdfhfjhf", /// "currencyMap" : { /// "coin" : { /// "purchased" : NumberLong(0), /// "balance" : NumberLong(5000), /// "consumed" : NumberLong(0), /// "awarded" : NumberLong(5000) /// }, /// "bar" : { /// "purchased" : NumberLong(0), /// "balance" : NumberLong(2), /// "consumed" : NumberLong(0), /// "awarded" : NumberLong(2) /// } /// }, /// "createdAt" : 763578645786, /// "updatedAt" : 8692486255764, /// }, /// "appleReceipt" : "gsgsfvgvg", /// "status" : 0, /// "server_time" : 987490827457 /// } /// } /// </returns> public void VerifyItunesReceipt(String in_base64EncReceiptData, SuccessCallback in_callback = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> message = new Dictionary<string, object>(); message[OperationParam.ProductServiceOpCashInReceiptReceipt.Value] = in_base64EncReceiptData; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_callback, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.CashInReceipt, message, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Initialize Steam Transaction /// </summary> /// <remarks> /// Service Name - product /// Service Operation - INITIALIZE_STEAM_TRANSACTION /// </remarks> /// <param name="in_language"> /// ISO 639-1 language code /// </param> /// <param name="in_items"> /// Items to purchase /// </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": /// { /// "steamStatus" : 200, /// "steamData" : /// { /// } /// } /// } /// </returns> public void StartSteamTransaction( String in_language, String in_itemId, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ProductServiceLanguage.Value] = in_language; data[OperationParam.ProductServiceItemId.Value] = in_itemId; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.StartSteamTransaction, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Resets the player's currency back to zero. /// </summary> /// <remarks> /// Service Name - Product /// Service Operation - ResetPlayerVC /// </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 ResetCurrency( 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.Product, ServiceOperation.ResetPlayerVC, null, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Method gets the active sales inventory for the passed-in /// currency type and category. /// </summary> /// <remarks> /// Service Name - Product /// Service Operation - GetInventory /// </remarks> /// <param name="in_platform"> /// The store platform. Valid stores are: /// - iTunes /// - Facebook /// - AppWorld /// - Steam /// - Windows /// - WindowsPhone /// - GooglePlay /// </param> /// <param name="in_userCurrency"> /// The currency to retrieve the sales /// inventory for. This is only used for Steam and Facebook stores. /// </param> /// <param name="in_category"> /// The product category /// </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":{ /// "product_inventory":[ /// { /// "gameId":"com.roger.football", /// "itemId":"0000001", /// "title":"Item 0000001", /// "description":"Buy 5 footballs", /// "imageUrl":"http:", /// "fbUrl":"http:", /// "currency":{"footballs":5}, /// "priceData":{"currency":"USD","price":1000} /// } /// ], /// "server_time":1398960658981 /// } /// } /// </returns> public void GetSalesInventoryByCategory( string in_platform, string in_userCurrency, string in_category, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ProductServiceGetInventoryPlatform.Value] = in_platform; if (Util.IsOptionalParameterValid(in_userCurrency)) { data[OperationParam.ProductServiceGetInventoryUserCurrency.Value] = in_userCurrency; } if (Util.IsOptionalParameterValid(in_category)) { data[OperationParam.ProductServiceGetInventoryCategory.Value] = in_category; } ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.GetInventory, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Returns the eligible promotions for the player. /// </summary> /// <remarks> /// Service Name - Product /// Service Operation - EligiblePromotions /// </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":{ /// "promotions": [ /// { /// "gameId": "10019", /// "promotionId": 9, /// "type": "SCHEDULED", /// "name": "session >= 2", /// "message": "test1", /// "enabled": true, /// "targetAllUsers": false, /// "segments": [ /// 5 /// ], /// "prices": [ /// { /// "itemId": "regGems150", /// "priceId": 1 /// } /// ], /// "notifications": [ /// { /// "trigger": "ACTIVATED", /// "notificationTemplateId": 10 /// } /// ], /// "startAt": 1415374185745, /// "endAt": 1415806185745, /// "createdAt": 0, /// "updatedAt": 1415729753294 /// } /// ] /// } /// } /// </returns> public void GetEligiblePromotions( 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.Product, ServiceOperation.EligiblePromotions, null, callback); m_brainCloudClientRef.SendRequest(sc); }
private void Authenticate( string in_externalId, string in_authenticationToken, string in_authenticationType, string in_externalAuthName, bool in_forceCreate, SuccessCallback in_success, FailureCallback in_failure, object in_cbObject) { string languageCode = Util.GetIsoCodeForCurrentLanguage(); double utcOffset = Util.GetUTCOffsetForCurrentTimeZone(); string countryCode = Util.GetCurrentCountryCode(); Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.AuthenticateServiceAuthenticateExternalId.Value] = in_externalId; data[OperationParam.AuthenticateServiceAuthenticateAuthenticationToken.Value] = in_authenticationToken; data[OperationParam.AuthenticateServiceAuthenticateAuthenticationType.Value] = in_authenticationType; data[OperationParam.AuthenticateServiceAuthenticateForceCreate.Value] = in_forceCreate; data[OperationParam.AuthenticateServiceAuthenticateProfileId.Value] = m_profileId; data[OperationParam.AuthenticateServiceAuthenticateAnonymousId.Value] = m_anonymousId; data[OperationParam.AuthenticateServiceAuthenticateGameId.Value] = m_brainCloudClientRef.GameId; data[OperationParam.AuthenticateServiceAuthenticateReleasePlatform.Value] = m_brainCloudClientRef.ReleasePlatform; data[OperationParam.AuthenticateServiceAuthenticateGameVersion.Value] = m_brainCloudClientRef.GameVersion; data[OperationParam.AuthenticateServiceAuthenticateBrainCloudVersion.Value] = Version.GetVersion(); if (Util.IsOptionalParameterValid(in_externalAuthName)) { data[OperationParam.AuthenticateServiceAuthenticateExternalAuthName.Value] = in_externalAuthName; } data[OperationParam.AuthenticateServiceAuthenticateCountryCode.Value] = countryCode; data[OperationParam.AuthenticateServiceAuthenticateLanguageCode.Value] = languageCode; data[OperationParam.AuthenticateServiceAuthenticateTimeZoneOffset.Value] = utcOffset; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Authenticate, ServiceOperation.Authenticate, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Updates the "friend summary data" associated with the logged in player. /// Some operations will return this summary data. For instance the social /// leaderboards will return the player's score in the leaderboard along /// with the friend summary data. Generally this data is used to provide /// a quick overview of the player without requiring a separate API call /// to read their public stats or entity data. /// /// Note this API call pre-dates the shared player data api (public entity/stats) /// and thus usage for anything outside of social leaderboards should be /// deprecated. /// </summary> /// <remarks> /// Service Name - PlayerState /// Service Operation - UpdateSummary /// </remarks> /// <param name="in_jsonSummaryData"> /// A JSON string defining the summary data. /// For example: /// { /// "xp":123, /// "level":12, /// "highScore":45123 /// } /// </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 UpdateSummaryFriendData( string in_jsonSummaryData, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); if (Util.IsOptionalParameterValid(in_jsonSummaryData)) { Dictionary<string, object> summaryData = JsonReader.Deserialize<Dictionary<string, object>> (in_jsonSummaryData); data[OperationParam.PlayerStateServiceUpdateFriendSummaryData.Value] = summaryData; } else data = null; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.PlayerState, ServiceOperation.UpdateSummary, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <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> /// Starts a stream /// </summary> /// <remarks> /// Service Name - PlaybackStream /// Service Operation - StartStream /// </remarks> /// <param name="in_targetPlayerId"> /// The player to start a stream with /// </param> /// <param name="in_includeSharedData"> /// Whether to include shared data in the stream /// </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": { /// "playbackStreamId": "b8da4619-2ddc-4184-b654-cd11d12a3275", /// "gameId": "10000", /// "initiatingPlayerId": "198bcafcd-6e84-4c30-9f6e-3f9f016440c6", /// "targetPlayerId": "a6943c74-6655-4245-8b2b-13bb908d3f88", /// "status": "STARTED", /// "summary": {}, /// "initialSharedData": { /// "entities": [], /// "statistics": {} /// }, /// "events": [], /// "createdAt": 1425481184200, /// "updatedAt": 1425481184200 /// } /// } /// </returns> public void StartStream( string in_targetPlayerId, bool in_includeSharedData, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.PlaybackStreamServiceTargetPlayerId.Value] = in_targetPlayerId; data[OperationParam.PlaybackStreamServiceIncludeSharedData.Value] = in_includeSharedData; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.PlaybackStream, ServiceOperation.StartStream, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Gets stream summaries for target player /// </summary> /// <remarks> /// Service Name - PlaybackStream /// Service Operation - GetStreamSummariesForTargetPlayer /// </remarks> /// <param name="in_targetPlayerId"> /// The player that started the stream /// </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": { /// "streams": [ /// { /// "playbackStreamId": "b8da4619-2ddc-4184-b654-cd11d12a3275", /// "gameId": "10000", /// "initiatingPlayerId": "198bcadb-6e84-4c30-9f6e-3f9f016440c6", /// "targetPlayerId": "a6943c74-6636-4245-8b2b-13bb908d3f88", /// "status": "IN_PROGRESS", /// "summary": { /// "total": 5 /// }, /// "createdAt": 1425481184200, /// "updatedAt": 1425484485139 /// } /// ] /// } /// } /// </returns> public void GetStreamSummariesForTargetPlayer( string in_targetPlayerId, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.PlaybackStreamServiceTargetPlayerId.Value] = in_targetPlayerId; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.PlaybackStream, ServiceOperation.GetStreamSummariesForTargetPlayer, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Reads a subset of global statistics as defined by the input JSON. /// </summary> /// <remarks> /// Service Name - GlobalStatistics /// Service Operation - ReadSubset /// </remarks> /// <param name="in_jsonData"> /// The json data containing an array of statistics to read: /// [ /// "Level01_TimesBeaten", /// "Level02_TimesBeaten" /// ] /// </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 with the subset of global statistics: /// { /// "status":200, /// "data":{ /// "statisticsExceptions":{ /// }, /// "statistics":{ /// "Level02_TimesBeaten":11, /// "Level01_TimesBeaten":1 /// } /// } /// } /// </returns> public void ReadGlobalStatsSubset( string in_jsonData, SuccessCallback in_success, FailureCallback in_failure, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); object[] statsSubset = JsonReader.Deserialize<object[]>(in_jsonData); data[OperationParam.PlayerStatisticsServiceStats.Value] = statsSubset; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.GlobalStatistics, ServiceOperation.ReadSubset, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Handles the response bundle and calls registered callbacks. /// </summary> /// <param name="in_jsonData">The received message bundle.</param> private void HandleResponseBundle(string in_jsonData) { m_brainCloudClientRef.Log("INCOMING: " + in_jsonData); JsonResponseBundleV2 bundleObj = JsonReader.Deserialize <JsonResponseBundleV2>(in_jsonData); long receivedPacketId = (long)bundleObj.packetId; if (m_expectedIncomingPacketId == NO_PACKET_EXPECTED || m_expectedIncomingPacketId != receivedPacketId) { m_brainCloudClientRef.Log("Dropping duplicate packet"); return; } m_expectedIncomingPacketId = NO_PACKET_EXPECTED; Dictionary <string, object>[] responseBundle = bundleObj.responses; Dictionary <string, object> response = null; Exception firstThrownException = null; int numExceptionsThrown = 0; for (int j = 0; j < responseBundle.Length; ++j) { response = responseBundle[j]; int statusCode = (int)response["status"]; string data = ""; // // It's important to note here that a user error callback *might* call // ResetCommunications() based on the error being returned. // ResetCommunications will clear the m_serviceCallsInProgress List // effectively removing all registered callbacks for this message bundle. // It's also likely that the developer will want to call authenticate next. // We need to ensure that this is supported as it's the best way to // reset the brainCloud communications after a session invalid or network // error is triggered. // // This is safe to do from the main thread but just in case someone // calls this method from another thread, we lock on m_serviceCallsWaiting // ServerCall sc = null; lock (m_serviceCallsWaiting) { if (m_serviceCallsInProgress.Count > 0) { sc = m_serviceCallsInProgress[0] as ServerCall; m_serviceCallsInProgress.RemoveAt(0); } } // its a success response if (statusCode == 200) { if (response[OperationParam.ServiceMessageData.Value] != null) { Dictionary <string, object> responseData = (Dictionary <string, object>)response[OperationParam.ServiceMessageData.Value]; // send the data back as not formatted data = JsonWriter.Serialize(response); // save the session ID try { if (getJsonString(responseData, OperationParam.ServiceMessageSessionId.Value, null) != null) { m_sessionID = (string)responseData[OperationParam.ServiceMessageSessionId.Value]; m_isAuthenticated = true; // TODO confirm authentication } // save the profile ID if (getJsonString(responseData, OperationParam.ServiceMessageProfileId.Value, null) != null) { m_brainCloudClientRef.AuthenticationService.ProfileId = (string)responseData[OperationParam.ServiceMessageProfileId.Value]; } } catch (Exception e) { m_brainCloudClientRef.Log("SessionId or ProfileId do not exist " + e.ToString()); } } // now try to execute the callback if (sc != null) { if (sc.GetService().Equals(ServiceName.PlayerState.Value) && (sc.GetOperation().Equals(ServiceOperation.FullReset.Value) || sc.GetOperation().Equals(ServiceOperation.Reset.Value) || sc.GetOperation().Equals(ServiceOperation.Logout.Value))) { // we reset the current player or logged out // we are no longer authenticated m_isAuthenticated = false; m_brainCloudClientRef.AuthenticationService.ProfileId = null; } else if (sc.GetService().Equals(ServiceName.Authenticate.Value) && sc.GetOperation().Equals(ServiceOperation.Authenticate.Value)) { ProcessAuthenticate(data); } // // only process callbacks that are real if (sc.GetCallback() != null) { try { sc.GetCallback().OnSuccessCallback(data); } catch (Exception e) { m_brainCloudClientRef.Log(e.StackTrace); ++numExceptionsThrown; if (firstThrownException == null) { firstThrownException = e; } } } } } else if (statusCode >= 400 || statusCode == 202) { object reasonCodeObj = null, statusMessageObj = null; int reasonCode = 0; string statusMessage = ""; if (response.TryGetValue("reason_code", out reasonCodeObj)) { reasonCode = (int)reasonCodeObj; } if (response.TryGetValue("status_message", out statusMessageObj)) { statusMessage = (string)statusMessageObj; } if (reasonCode == ReasonCodes.SESSION_EXPIRED || reasonCode == ReasonCodes.SESSION_NOT_FOUND_ERROR) { m_isAuthenticated = false; m_brainCloudClientRef.Log("Received session expired or not found, need to re-authenticate"); } // now try to execute the callback if (sc != null && sc.GetCallback() != null) { try { sc.GetCallback().OnErrorCallback(statusCode, reasonCode, statusMessage); } catch (Exception e) { m_brainCloudClientRef.Log(e.StackTrace); ++numExceptionsThrown; if (firstThrownException == null) { firstThrownException = e; } } } } } if (firstThrownException != null) { m_activeRequest = null; // to make sure we don't reprocess this message throw new Exception("User callback handlers threw " + numExceptionsThrown + " exception(s)." + " See the Unity log for callstacks or inner exception for first exception thrown.", firstThrownException); } }
/// <summary> /// Verify Microsoft Receipt. On success, the player will be awarded the /// associated currencies. /// </summary> /// <remarks> /// Service Name - product /// Service Operation - VERIFY_MICROSOFT_RECEIPT /// </remarks> /// <param name="in_receipt"> /// Receipt XML /// </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": /// { /// "result" : "OK" /// } /// } /// </returns> public void VerifyMicrosoftReceipt( string in_receipt, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ProductServiceReceipt.Value] = in_receipt; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.VerifyMicrosoftReceipt, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Confirm Facebook Purchase. On success, the player will be awarded the /// associated currencies. /// </summary> /// <remarks> /// Service Name - product /// Service Operation - FB_CONFIRM_PURCHASE /// </remarks> /// <param name="in_signedRequest"> /// signed_request object received from Facebook /// </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": /// { /// "result" : "OK" /// } /// } /// </returns> public void ConfirmFacebookPurchase( string in_signedRequest, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ProductServiceSignedRequest.Value] = in_signedRequest; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.FbConfirmPurchase, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Returns list of friends with optional summary data. /// </summary> /// <remarks> /// Service Name - Friend /// Service Operation - ReadFriendsWithApplication /// </remarks> /// <param name="in_includeSummaryData"> /// Whether to include summary data /// </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 /// </returns> public void ReadFriendsWithApplication( bool in_includeSummaryData, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.FriendServiceIncludeSummaryData.Value] = in_includeSummaryData; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Friend, ServiceOperation.ReadFriendsWithApplication, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Confirm GooglePlay Purchase. On success, the player will be awarded the /// associated currencies. /// </summary> /// <remarks> /// Service Name - product /// Service Operation - CONFIRM_GOOGLEPLAY_PURCHASE /// </remarks> /// <param name="in_orderId"> /// GooglePlay order id /// </param> /// <param name="in_productId"> /// GooglePlay product id /// </param> /// <param name="in_token"> /// GooglePlay token string /// </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": /// { /// "result" : "OK" /// } /// } /// </returns> public void ConfirmGooglePlayPurchase( string in_orderId, string in_productId, string in_token, SuccessCallback in_success = null, FailureCallback in_failure = null, object in_cbObject = null) { Dictionary<string, object> data = new Dictionary<string, object>(); data[OperationParam.ProductServiceOrderId.Value] = in_orderId; data[OperationParam.ProductServiceProductId.Value] = in_productId; data[OperationParam.ProductServiceToken.Value] = in_token; ServerCallback callback = BrainCloudClient.CreateServerCallback(in_success, in_failure, in_cbObject); ServerCall sc = new ServerCall(ServiceName.Product, ServiceOperation.GooglePlayConfirmPurchase, data, callback); m_brainCloudClientRef.SendRequest(sc); }
/// <summary> /// Handles the response bundle and calls registered callbacks. /// </summary> /// <param name="in_jsonData">The received message bundle.</param> private void HandleResponseBundle(string in_jsonData) { m_brainCloudClientRef.Log("INCOMING: " + in_jsonData); JsonResponseBundleV2 bundleObj = JsonReader.Deserialize <JsonResponseBundleV2>(in_jsonData); long receivedPacketId = (long)bundleObj.packetId; if (m_expectedIncomingPacketId == NO_PACKET_EXPECTED || m_expectedIncomingPacketId != receivedPacketId) { m_brainCloudClientRef.Log("Dropping duplicate packet"); return; } m_expectedIncomingPacketId = NO_PACKET_EXPECTED; Dictionary <string, object>[] responseBundle = bundleObj.responses; Dictionary <string, object> response = null; IList <Exception> exceptions = new List <Exception>(); for (int j = 0; j < responseBundle.Length; ++j) { response = responseBundle[j]; int statusCode = (int)response["status"]; string data = ""; // // It's important to note here that a user error callback *might* call // ResetCommunications() based on the error being returned. // ResetCommunications will clear the m_serviceCallsInProgress List // effectively removing all registered callbacks for this message bundle. // It's also likely that the developer will want to call authenticate next. // We need to ensure that this is supported as it's the best way to // reset the brainCloud communications after a session invalid or network // error is triggered. // // This is safe to do from the main thread but just in case someone // calls this method from another thread, we lock on m_serviceCallsWaiting // ServerCall sc = null; lock (m_serviceCallsWaiting) { if (m_serviceCallsInProgress.Count > 0) { sc = m_serviceCallsInProgress[0] as ServerCall; m_serviceCallsInProgress.RemoveAt(0); } } // its a success response if (statusCode == 200) { Dictionary <string, object> responseData = null; if (response[OperationParam.ServiceMessageData.Value] != null) { responseData = (Dictionary <string, object>)response[OperationParam.ServiceMessageData.Value]; // send the data back as not formatted data = JsonWriter.Serialize(response); // save the session ID try { if (getJsonString(responseData, OperationParam.ServiceMessageSessionId.Value, null) != null) { m_sessionID = (string)responseData[OperationParam.ServiceMessageSessionId.Value]; m_isAuthenticated = true; // TODO confirm authentication } // save the profile ID if (getJsonString(responseData, OperationParam.ServiceMessageProfileId.Value, null) != null) { m_brainCloudClientRef.AuthenticationService.ProfileId = (string)responseData[OperationParam.ServiceMessageProfileId.Value]; } } catch (Exception e) { m_brainCloudClientRef.Log("SessionId or ProfileId do not exist " + e.ToString()); } } // now try to execute the callback if (sc != null) { if (sc.GetService().Equals(ServiceName.PlayerState.Value) && (sc.GetOperation().Equals(ServiceOperation.FullReset.Value) || sc.GetOperation().Equals(ServiceOperation.Logout.Value))) { // we reset the current player or logged out // we are no longer authenticated m_isAuthenticated = false; m_brainCloudClientRef.AuthenticationService.ClearSavedProfileID(); } else if (sc.GetService().Equals(ServiceName.Authenticate.Value) && sc.GetOperation().Equals(ServiceOperation.Authenticate.Value)) { ProcessAuthenticate(data); } // // only process callbacks that are real if (sc.GetCallback() != null) { try { sc.GetCallback().OnSuccessCallback(data); } catch (Exception e) { m_brainCloudClientRef.Log(e.StackTrace); exceptions.Add(e); } } // now deal with rewards if (m_rewardCallback != null && responseData != null) { try { Dictionary <string, object> rewards = null; // it's an operation that return a reward if (sc.GetService().Equals(ServiceName.Authenticate.Value) && sc.GetOperation().Equals(ServiceOperation.Authenticate.Value)) { object objRewards = null; if (responseData.TryGetValue("rewards", out objRewards)) { Dictionary <string, object> outerRewards = (Dictionary <string, object>)objRewards; if (outerRewards.TryGetValue("rewards", out objRewards)) { Dictionary <string, object> innerRewards = (Dictionary <string, object>)objRewards; if (innerRewards.Count > 0) { // we found rewards rewards = outerRewards; } } } } else if ((sc.GetService().Equals(ServiceName.PlayerStatistics.Value) && sc.GetOperation().Equals(ServiceOperation.Update.Value)) || (sc.GetService().Equals(ServiceName.PlayerStatisticsEvent.Value) && (sc.GetOperation().Equals(ServiceOperation.Trigger.Value) || sc.GetOperation().Equals(ServiceOperation.TriggerMultiple.Value)))) { object objRewards = null; if (responseData.TryGetValue("rewards", out objRewards)) { Dictionary <string, object> innerRewards = (Dictionary <string, object>)objRewards; if (innerRewards.Count > 0) { // we found rewards rewards = responseData; } } } if (rewards != null) { Dictionary <string, object> theReward = new Dictionary <string, object>(); theReward["rewards"] = rewards; theReward["service"] = sc.GetService(); theReward["operation"] = sc.GetOperation(); Dictionary <string, object> apiRewards = new Dictionary <string, object>(); List <object> rewardList = new List <object>(); rewardList.Add(theReward); apiRewards["apiRewards"] = rewardList; string rewardsAsJson = JsonWriter.Serialize(apiRewards); m_rewardCallback(rewardsAsJson); } } catch (Exception e) { m_brainCloudClientRef.Log(e.StackTrace); exceptions.Add(e); } } } } else if (statusCode >= 400 || statusCode == 202) { object reasonCodeObj = null, statusMessageObj = null; int reasonCode = 0; string errorJson = ""; if (response.TryGetValue("reason_code", out reasonCodeObj)) { reasonCode = (int)reasonCodeObj; } if (m_oldStyleStatusResponseInErrorCallback) { if (response.TryGetValue("status_message", out statusMessageObj)) { errorJson = (string)statusMessageObj; } } else { errorJson = JsonWriter.Serialize(response); } if (reasonCode == ReasonCodes.PLAYER_SESSION_EXPIRED || reasonCode == ReasonCodes.NO_SESSION) { m_isAuthenticated = false; m_brainCloudClientRef.Log("Received session expired or not found, need to re-authenticate"); } if (sc != null && sc.GetOperation().Equals(ServiceOperation.Logout.Value)) { if (reasonCode == ReasonCodes.CLIENT_NETWORK_ERROR_TIMEOUT) { m_isAuthenticated = false; m_brainCloudClientRef.Log("Could not communicate with the server on logout due to network timeout"); } } // now try to execute the callback if (sc != null && sc.GetCallback() != null) { try { sc.GetCallback().OnErrorCallback(statusCode, reasonCode, errorJson); } catch (Exception e) { m_brainCloudClientRef.Log(e.StackTrace); exceptions.Add(e); } } } } if (bundleObj.events != null && m_eventCallback != null) { Dictionary <string, Dictionary <string, object>[]> eventsJsonObj = new Dictionary <string, Dictionary <string, object>[]>(); eventsJsonObj["events"] = bundleObj.events; string eventsAsJson = JsonWriter.Serialize(eventsJsonObj); try { m_eventCallback(eventsAsJson); } catch (Exception e) { m_brainCloudClientRef.Log(e.StackTrace); exceptions.Add(e); } } if (exceptions.Count > 0) { m_activeRequest = null; // to make sure we don't reprocess this message throw new Exception("User callback handlers threw " + exceptions.Count + " exception(s)." + " See the Unity log for callstacks or inner exception for first exception thrown.", exceptions[0]); } }
/// <summary> /// Sends the heartbeat. /// </summary> private void SendHeartbeat() { ServerCall sc = new ServerCall(ServiceName.HeartBeat, ServiceOperation.Read, null, null); AddToQueue(sc); }