コード例 #1
0
        /// <summary>
        /// Start session, the function responsible for creating SessionID and gathering information about user and device
        /// </summary>
        /// <param name="entityKey">Result of the user's login, consist of entity info</param>
        /// <param name="playFabUserId">Result of the user's login, represent user ID</param>
        public void ClientSessionStart(EntityModels.EntityKey entityKey, string playFabUserId)
        {
            gameSessionID = Guid.NewGuid();

            entityInfo = entityKey;

            EventContents eventInfo = new EventContents();

            eventInfo.Name              = "client_session_start";
            eventInfo.EventNamespace    = eventNamespace;
            eventInfo.Entity            = entityInfo;
            eventInfo.OriginalTimestamp = DateTime.UtcNow;

            var payload = new Dictionary <string, object>
            {
                { "UserID", playFabUserId },
                { "DeviceType", SystemInfo.deviceType },
                { "DeviceModel", SystemInfo.deviceModel },
                { "OS", SystemInfo.operatingSystem },
                { "ClientSessionID", gameSessionID },
            };

            eventInfo.Payload = payload;
            eventsRequests.Enqueue(eventInfo);
        }
コード例 #2
0
        public static void OnPlayFabLogin(PlayFabResultCommon result)
        {
            var loginResult    = result as LoginResult;
            var registerResult = result as RegisterPlayFabUserResult;

            if (loginResult == null && registerResult == null)
            {
                return;
            }

            _needsAttribution = false;
            _gatherInfo       = false;
            if (loginResult != null && loginResult.SettingsForUser != null)
            {
                _needsAttribution = loginResult.SettingsForUser.NeedsAttribution;
            }
            else if (registerResult != null && registerResult.SettingsForUser != null)
            {
                _needsAttribution = registerResult.SettingsForUser.NeedsAttribution;
            }
            if (loginResult != null && loginResult.SettingsForUser != null)
            {
                _gatherInfo = loginResult.SettingsForUser.GatherDeviceInfo;
            }
            else if (registerResult != null && registerResult.SettingsForUser != null)
            {
                _gatherInfo = registerResult.SettingsForUser.GatherDeviceInfo;
            }

            // Device attribution (adid or idfa)
            if (PlayFabSettings.AdvertisingIdType != null && PlayFabSettings.AdvertisingIdValue != null)
            {
                DoAttributeInstall();
            }
            else
            {
                GetAdvertIdFromUnity();
            }

            // Device information gathering
            SendDeviceInfoToPlayFab();

#if ENABLE_PLAYFABENTITY_API
            string playFabUserId             = loginResult.PlayFabId;
            EntityModels.EntityKey entityKey = new EntityModels.EntityKey();
            if (loginResult.EntityToken != null)
            {
                entityKey.Id         = loginResult.EntityToken.Entity.Id;
                entityKey.Type       = (PlayFab.EntityModels.EntityTypes)(int) loginResult.EntityToken.Entity.Type; // possible loss of data
                entityKey.TypeString = loginResult.EntityToken.Entity.TypeString;

                PlayFabHttp.InitializeScreenTimeTracker(entityKey, playFabUserId);
            }
            else
            {
                PlayFabHttp.shouldCollectScreenTime = false;
            }
#endif
        }
コード例 #3
0
        /// <summary>
        /// Separated from OnPlayFabLogin, to explicitly lose the refs to loginResult and registerResult, because
        ///   only one will be defined, but both usually have all the information we REALLY need here.
        /// But the result signatures are different and clunky, so do the separation above, and processing here
        /// </summary>
        private static void _OnPlayFabLogin(ClientModels.UserSettings settingsForUser, string playFabId, ClientModels.EntityTokenResponse entityInfo)
        {
            _needsAttribution = _gatherDeviceInfo = _gatherScreenTime = false;
            if (settingsForUser != null)
            {
                _needsAttribution = settingsForUser.NeedsAttribution;
                _gatherDeviceInfo = settingsForUser.GatherDeviceInfo;
                _gatherScreenTime = settingsForUser.GatherFocusInfo;
            }

            // Device attribution (adid or idfa)
            if (PlayFabSettings.AdvertisingIdType != null && PlayFabSettings.AdvertisingIdValue != null)
            {
                DoAttributeInstall();
            }
            else
            {
                GetAdvertIdFromUnity();
            }

            // Device information gathering
            SendDeviceInfoToPlayFab();

#if ENABLE_PLAYFABENTITY_API
            string playFabUserId             = playFabId;
            EntityModels.EntityKey entityKey = new EntityModels.EntityKey();
            if (entityInfo != null && _gatherScreenTime)
            {
                entityKey.Id         = entityInfo.Entity.Id;
                entityKey.Type       = (EntityModels.EntityTypes)(int) entityInfo.Entity.Type; // possible loss of data
                entityKey.TypeString = entityInfo.Entity.TypeString;

                PlayFabHttp.InitializeScreenTimeTracker(entityKey, playFabUserId);
            }
            else
            {
                PlayFabSettings.DisableFocusTimeCollection = true;
            }
#endif
        }
コード例 #4
0
 /// <summary>
 /// This initializes ScreenTimeTracker object and notifying it to start sending info.
 /// </summary>
 /// <param name="entityKey">Result of the user's login, consist of entity info</param>
 /// <param name="playFabUserId">Result of the user's login, represent user ID</param>
 public static void InitializeScreenTimeTracker(EntityModels.EntityKey entityKey, string playFabUserId)
 {
     screenTimeTracker.ClientSessionStart(entityKey, playFabUserId);
     instance.StartCoroutine(SendScreenTimeEvents(delayBetweenBatches));
 }
コード例 #5
0
ファイル: PlayFabApiTest.cs プロジェクト: iomac/SDKGenerator
 private void GetEntityTokenContinued(PlayFabResult <GetEntityTokenResponse> result, UUnitTestContext testContext, string failMessage)
 {
     entityKey = result.Result.Entity;
 }