コード例 #1
0
 public Session(AbstractLogger logger, IInternalLocalUser localUser, string guestControllerAccessToken, bool pushNotificationsEnabled, INotificationPoller notificationPoller, ICoroutineManager coroutineManager, IDatabase database, IUserDatabase userDatabase, IGuestControllerClient guestControllerClient, IMixWebCallFactory mixWebCallFactory, IEpochTime epochTime, DatabaseCorruptionHandler databaseCorruptionHandler, ISessionStatus sessionStatus, IKeychain keychain, IGetStateResponseParser getStateResponseParser, string clientVersion, INotificationQueue notificationQueue)
 {
     this.logger                                     = logger;
     this.localUser                                  = localUser;
     this.notificationPoller                         = notificationPoller;
     this.coroutineManager                           = coroutineManager;
     this.database                                   = database;
     this.userDatabase                               = userDatabase;
     this.guestControllerClient                      = guestControllerClient;
     this.mixWebCallFactory                          = mixWebCallFactory;
     this.epochTime                                  = epochTime;
     this.databaseCorruptionHandler                  = databaseCorruptionHandler;
     this.sessionStatus                              = sessionStatus;
     this.keychain                                   = keychain;
     this.getStateResponseParser                     = getStateResponseParser;
     this.clientVersion                              = clientVersion;
     this.notificationQueue                          = notificationQueue;
     GuestControllerAccessToken                      = guestControllerAccessToken;
     guestControllerClient.OnAccessTokenChanged     += HandleGuestControllerAccessTokenChanged;
     guestControllerClient.OnAuthenticationLost     += HandleAuthenticationLost;
     mixWebCallFactory.OnAuthenticationLost         += HandleAuthenticationLost;
     localUser.OnPushNotificationsToggled           += HandlePushNotificationsToggled;
     localUser.OnPushNotificationReceived           += HandlePushNotificationReceived;
     localUser.OnDisplayNameUpdated                 += HandleDisplayNameUpdated;
     databaseCorruptionHandler.OnCorruptionDetected += HandleCorruptionDetected;
     updateEnumerator                                = Update();
     coroutineManager.Start(updateEnumerator);
     notificationPoller.OnNotificationsPolled += HandleNotificationsPolled;
     notificationPoller.UsePollIntervals       = !pushNotificationsEnabled;
     this.sessionStatus.IsPaused = true;
     notificationPoller.OnSynchronizationError += HandleNotificationPollerSynchronizationError;
 }
コード例 #2
0
 public SessionFactory(AbstractLogger logger, ICoroutineManager coroutineManager, IStopwatch pollCountdownStopwatch, IEpochTime epochTime, DatabaseCorruptionHandler databaseCorruptionHandler, INotificationQueue notificationQueue, INotificationDispatcher notificationDispatcher, ISessionStatus sessionStatus, IMixWebCallFactoryFactory mixWebCallFactoryFactory, IWebCallEncryptorFactory webCallEncryptorFactory, IMixSessionStarter mixSessionStarter, IKeychain keychain, ISessionRefresherFactory sessionRefresherFactory, IGuestControllerClientFactory guestControllerClientFactory, IRandom random, IEncryptor encryptor, IFileSystem fileSystem, IWwwCallFactory wwwCallFactory, string localStorageDirPath, string clientVersion, IDatabaseDirectoryCreator databaseDirectoryCreator, IDocumentCollectionFactory documentCollectionFactory, IDatabase database)
 {
     this.logger                       = logger;
     this.coroutineManager             = coroutineManager;
     this.pollCountdownStopwatch       = pollCountdownStopwatch;
     this.epochTime                    = epochTime;
     this.databaseCorruptionHandler    = databaseCorruptionHandler;
     this.notificationQueue            = notificationQueue;
     this.notificationDispatcher       = notificationDispatcher;
     this.sessionStatus                = sessionStatus;
     this.mixWebCallFactoryFactory     = mixWebCallFactoryFactory;
     this.webCallEncryptorFactory      = webCallEncryptorFactory;
     this.mixSessionStarter            = mixSessionStarter;
     this.keychain                     = keychain;
     this.sessionRefresherFactory      = sessionRefresherFactory;
     this.guestControllerClientFactory = guestControllerClientFactory;
     this.random                       = random;
     this.encryptor                    = encryptor;
     this.fileSystem                   = fileSystem;
     this.wwwCallFactory               = wwwCallFactory;
     this.localStorageDirPath          = localStorageDirPath;
     this.clientVersion                = clientVersion;
     this.databaseDirectoryCreator     = databaseDirectoryCreator;
     this.documentCollectionFactory    = documentCollectionFactory;
     this.database                     = database;
 }
コード例 #3
0
 public NotificationPoller(AbstractLogger logger, IMixWebCallFactory webCallFactory, INotificationQueue queue, IStopwatch pollCountdownStopwatch, IGetStateResponseParser getStateResponseParser, IEpochTime epochTime, IRandom random, IDatabase database, string localUserSwid)
 {
     usePollIntervals        = true;
     missedNotificationTimes = new Dictionary <long, long>();
     isPaused                    = true;
     this.logger                 = logger;
     this.webCallFactory         = webCallFactory;
     this.queue                  = queue;
     this.pollCountdownStopwatch = pollCountdownStopwatch;
     this.getStateResponseParser = getStateResponseParser;
     this.epochTime              = epochTime;
     this.random                 = random;
     this.database               = database;
     this.localUserSwid          = localUserSwid;
     PollIntervals               = new int[1] {
         2147483647
     };
     PokeIntervals = new int[1] {
         2147483647
     };
     MaximumMissingNotificationTime = int.MaxValue;
     Jitter              = 0;
     IntervalIndex       = 0;
     queue.OnQueued     += HandleQueued;
     queue.OnDispatched += HandleQueueDispatched;
 }
コード例 #4
0
 public static bool StoreProfile(AbstractLogger logger, IDatabase database, IEpochTime epochTime, string swid, ProfileData profileData)
 {
     Disney.Mix.SDK.Internal.GuestControllerDomain.DisplayName displayNameData = profileData.displayName;
     if (displayNameData != null)
     {
         try
         {
             database.UpdateSessionDocument(swid, delegate(SessionDocument doc)
             {
                 doc.DisplayNameText           = displayNameData.displayName;
                 doc.ProposedDisplayName       = displayNameData.proposedDisplayName;
                 doc.ProposedDisplayNameStatus = displayNameData.proposedStatus;
                 doc.FirstName = profileData.profile.firstName;
                 doc.LastProfileRefreshTime = epochTime.Seconds;
                 doc.AccountStatus          = profileData.profile.status;
             });
         }
         catch (Exception arg)
         {
             logger.Critical("Unhandled exception: " + arg);
             return(false);
         }
     }
     return(true);
 }
コード例 #5
0
 public LocalUser(AbstractLogger logger, IDisplayName displayName, string swid, IList <IInternalFriend> friends, AgeBandType ageBandType, IDatabase database, IUserDatabase userDatabase, IInternalRegistrationProfile registrationProfile, IMixWebCallFactory mixWebCallFactory, IGuestControllerClient guestControllerClient, INotificationQueue notificationQueue, IEncryptor encryptor, IEpochTime epochTime)
 {
     DisplayName = displayName;
     FirstName   = registrationProfile.FirstName;
     Swid        = swid;
     Id          = swid;
     this.logger = logger;
     this.registrationProfile   = registrationProfile;
     this.mixWebCallFactory     = mixWebCallFactory;
     this.friends               = friends;
     this.ageBandType           = ageBandType;
     this.database              = database;
     this.userDatabase          = userDatabase;
     incomingFriendInvitations  = new List <IInternalIncomingFriendInvitation>();
     outgoingFriendInvitations  = new List <IInternalOutgoingFriendInvitation>();
     oldInvitationIds           = new List <long>();
     unidentifiedUsers          = new List <IInternalUnidentifiedUser>();
     this.guestControllerClient = guestControllerClient;
     this.notificationQueue     = notificationQueue;
     this.encryptor             = encryptor;
     this.epochTime             = epochTime;
     guestControllerClient.OnLegalMarketingUpdateRequired += delegate(object sender, AbstractLegalMarketingUpdateRequiredEventArgs e)
     {
         this.OnLegalMarketingUpdateRequired(this, e);
     };
 }
コード例 #6
0
ファイル: StateGetter.cs プロジェクト: smdx24/CPI-Source-Code
 public static void GetState(AbstractLogger logger, IEpochTime epochTime, string clientVersion, IDatabase database, IUserDatabase userDatabase, INotificationQueue notificationQueue, IMixWebCallFactory mixWebCallFactory, string localUserId, long lastNotificationTime, Action <GetStateResponse> successCallback, Action failureCallback)
 {
     try
     {
         GetStateRequest getStateRequest = new GetStateRequest();
         getStateRequest.UserId        = localUserId;
         getStateRequest.ClientVersion = clientVersion;
         GetStateRequest request = getStateRequest;
         IWebCall <GetStateRequest, GetStateResponse> webCall = mixWebCallFactory.StatePost(request);
         webCall.OnResponse += delegate(object sender, WebCallEventArgs <GetStateResponse> e)
         {
             HandleGetStateSuccess(logger, epochTime, database, userDatabase, notificationQueue, e.Response, mixWebCallFactory, successCallback, failureCallback);
         };
         webCall.OnError += delegate
         {
             failureCallback();
         };
         webCall.Execute();
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         failureCallback();
     }
 }
コード例 #7
0
ファイル: StateGetter.cs プロジェクト: smdx24/CPI-Source-Code
 private static void HandleGetStateSuccess(AbstractLogger logger, IEpochTime epochTime, IDatabase database, IUserDatabase userDatabase, INotificationQueue notificationQueue, GetStateResponse response, IMixWebCallFactory mixWebCallFactory, Action <GetStateResponse> successCallback, Action failureCallback)
 {
     try
     {
         if (ValidateResponse(response))
         {
             epochTime.ReferenceTime = response.Timestamp.Value;
             database.SetServerTimeOffsetMillis((long)epochTime.Offset.TotalMilliseconds);
             logger.Debug("New time offset: " + epochTime.Offset);
             successCallback(response);
             notificationQueue.LatestSequenceNumber = response.NotificationSequenceCounter.Value;
         }
         else
         {
             logger.Critical("Error validating get state response: " + JsonParser.ToJson(response));
             failureCallback();
             notificationQueue.Clear();
         }
     }
     catch (Exception ex)
     {
         logger.Critical("Unhandled exception: " + ex);
         failureCallback();
         notificationQueue.Clear();
     }
 }
コード例 #8
0
ファイル: Database.cs プロジェクト: smdx24/CPI-Source-Code
 public Database(byte[] encryptionKey, IRandom random, IEpochTime epochTime, IDatabaseDirectoryCreator directoryCreator, IDocumentCollectionFactory documentCollectionFactory, DatabaseCorruptionHandler databaseCorruptionHandler)
 {
     this.encryptionKey             = encryptionKey;
     this.random                    = random;
     this.epochTime                 = epochTime;
     this.directoryCreator          = directoryCreator;
     this.documentCollectionFactory = documentCollectionFactory;
     this.databaseCorruptionHandler = databaseCorruptionHandler;
 }
コード例 #9
0
 public MixWebCallFactoryFactory(AbstractLogger logger, string hostUrl, string mixClientToken, IWwwCallFactory wwwCallFactory, IMixWebCallQueue webCallQueue, IEpochTime epochTime, IDatabase database)
 {
     this.logger         = logger;
     this.hostUrl        = hostUrl;
     this.mixClientToken = mixClientToken;
     this.wwwCallFactory = wwwCallFactory;
     this.webCallQueue   = webCallQueue;
     this.epochTime      = epochTime;
     this.database       = database;
 }
コード例 #10
0
 public UserDatabase(IDocumentCollection <AlertDocument> alerts, IDocumentCollection <FriendDocument> friends, IDocumentCollection <FriendInvitationDocument> friendInvitations, IDocumentCollection <UserDocument> users, byte[] encryptionKey, string dirPath, IEpochTime epochTime, IDocumentCollectionFactory documentCollectionFactory, DatabaseCorruptionHandler databaseCorruptionHandler, ICoroutineManager coroutineManager)
 {
     this.alerts                    = alerts;
     this.friends                   = friends;
     this.friendInvitations         = friendInvitations;
     this.users                     = users;
     this.encryptionKey             = encryptionKey;
     this.dirPath                   = dirPath;
     this.epochTime                 = epochTime;
     this.documentCollectionFactory = documentCollectionFactory;
     this.databaseCorruptionHandler = databaseCorruptionHandler;
     this.coroutineManager          = coroutineManager;
     callbacks             = new Dictionary <long, Action>();
     pendingIndexedThreads = new List <long>();
 }
コード例 #11
0
 public MixWebCallFactory(AbstractLogger logger, string host, IWwwCallFactory wwwCallFactory, IWebCallEncryptor webCallEncryptor, string swid, string guestControllerAccessToken, string mixClientToken, IMixWebCallQueue webCallQueue, ISessionRefresher sessionRefresher, IEpochTime epochTime, IDatabase database)
 {
     this.logger                     = logger;
     this.host                       = host;
     this.wwwCallFactory             = wwwCallFactory;
     this.webCallEncryptor           = webCallEncryptor;
     this.swid                       = swid;
     this.guestControllerAccessToken = guestControllerAccessToken;
     this.mixClientToken             = mixClientToken;
     this.webCallQueue               = webCallQueue;
     this.sessionRefresher           = sessionRefresher;
     this.epochTime                  = epochTime;
     this.database                   = database;
     webCalls = new List <IDisposable>();
 }
コード例 #12
0
 public static void Handle(INotificationDispatcher dispatcher, IUserDatabase userDatabase, IInternalLocalUser localUser, IEpochTime epochTime)
 {
     dispatcher.OnAlertAdded += delegate(object sender, AbstractAddAlertNotificationEventArgs e)
     {
         HandleAlertAdded(localUser, userDatabase, e);
     };
     dispatcher.OnAlertCleared += delegate(object sender, AbstractClearAlertNotificationEventArgs e)
     {
         HandleAlertCleared(localUser, userDatabase, e);
     };
     dispatcher.OnFriendshipRemoved += delegate(object sender, AbstractRemoveFriendshipNotificationEventArgs e)
     {
         HandleFriendshipRemoved(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipTrustRemoved += delegate(object sender, AbstractRemoveFriendshipTrustNotificationEventArgs e)
     {
         HandleFriendshipTrustRemoved(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipInvitationAdded += delegate(object sender, AbstractAddFriendshipInvitationNotificationEventArgs e)
     {
         HandleFriendshipInvitationAdded(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipInvitationRemoved += delegate(object sender, AbstractRemoveFriendshipInvitationNotificationEventArgs e)
     {
         HandleFriendshipInvitationRemoved(userDatabase, localUser, e);
     };
     dispatcher.OnFriendshipAdded += delegate(object sender, AbstractAddFriendshipNotificationEventArgs e)
     {
         HandleFriendshipAdded(userDatabase, localUser, e);
     };
 }
コード例 #13
0
 private static void HandleUpdateProfileResult(AbstractLogger logger, IDatabase database, string swid, IEpochTime epochTime, GuestControllerResult <ProfileResponse> result, IInternalRegistrationProfile profile, Action <IUpdateProfileResult> callback)
 {
     try
     {
         if (!result.Success)
         {
             callback(new UpdateProfileResult(success: false, null));
         }
         else
         {
             IList <IInvalidProfileItemError> registerProfileItemErrors = GuestControllerErrorParser.GetRegisterProfileItemErrors(result.Response.error);
             if (result.Response.data == null)
             {
                 callback(new UpdateProfileResult(success: false, registerProfileItemErrors));
             }
             else
             {
                 ProfileData profileData = result.Response.data;
                 if (profileData.displayName != null)
                 {
                     database.UpdateSessionDocument(swid, delegate(SessionDocument doc)
                     {
                         doc.DisplayNameText           = profileData.displayName.displayName;
                         doc.ProposedDisplayName       = profileData.displayName.proposedDisplayName;
                         doc.ProposedDisplayNameStatus = profileData.displayName.proposedStatus;
                         doc.FirstName              = profileData.profile.firstName;
                         doc.AccountStatus          = profileData.profile.status;
                         doc.LastProfileRefreshTime = epochTime.Seconds;
                     });
                 }
                 profile.Update(profileData.profile, profileData.displayName, profileData.marketing);
                 callback(new UpdateProfileResult(success: true, registerProfileItemErrors));
             }
         }
     }
     catch (Exception arg)
     {
         logger.Critical("Unhandled exception: " + arg);
         callback(new UpdateProfileResult(success: false, null));
     }
 }
コード例 #14
0
 public static void UpdateProfile(AbstractLogger logger, IGuestControllerClient guestControllerClient, IDatabase database, string swid, IEpochTime epochTime, IInternalRegistrationProfile profile, string firstName, string lastName, string displayName, string email, string parentEmail, DateTime?dateOfBirth, IEnumerable <KeyValuePair <IMarketingItem, bool> > marketingAgreements, IEnumerable <ILegalDocument> acceptedLegalDocuments, Action <IUpdateProfileResult> callback)
 {
     try
     {
         Dictionary <string, string> dictionary = new Dictionary <string, string>();
         if (!string.IsNullOrEmpty(firstName))
         {
             dictionary.Add("firstName", firstName);
         }
         if (!string.IsNullOrEmpty(lastName))
         {
             dictionary.Add("lastName", lastName);
         }
         if (!string.IsNullOrEmpty(email))
         {
             dictionary.Add("email", email);
         }
         if (!string.IsNullOrEmpty(parentEmail))
         {
             dictionary.Add("parentEmail", parentEmail);
         }
         if (dateOfBirth.HasValue)
         {
             string value = dateOfBirth.Value.ToString("yyyy-MM-dd");
             dictionary.Add("dateOfBirth", value);
         }
         List <Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem> marketing = marketingAgreements?.Select((KeyValuePair <IMarketingItem, bool> pair) => new Disney.Mix.SDK.Internal.GuestControllerDomain.MarketingItem
         {
             code       = pair.Key.Id,
             subscribed = pair.Value
         }).ToList();
         List <string>   legalAssertions = acceptedLegalDocuments?.Select((ILegalDocument doc) => doc.Id).ToList();
         SessionDocument sessionDocument = database.GetSessionDocument(swid);
         guestControllerClient.UpdateProfile(new UpdateProfileRequest
         {
             etag        = sessionDocument.GuestControllerEtag,
             profile     = dictionary,
             marketing   = marketing,
             displayName = new RegisterDisplayName
             {
                 proposedDisplayName = displayName
             },
             legalAssertions = legalAssertions
         }, delegate(GuestControllerResult <ProfileResponse> r)
         {
             HandleUpdateProfileResult(logger, database, swid, epochTime, r, profile, callback);
         });
     }
     catch (Exception arg)
     {
         logger.Critical("Unhandled exception: " + arg);
         callback(new UpdateProfileResult(success: false, null));
     }
 }
コード例 #15
0
        public static void Resume(AbstractLogger logger, IGetStateResponseParser getStateResponseParser, IEpochTime epochTime, string clientVersion, INotificationQueue notificationQueue, IMixWebCallFactory mixWebCallFactory, IInternalLocalUser localUser, IDatabase database, IUserDatabase userDatabase, INotificationPoller notificationPoller, Action <IResumeSessionResult> callback)
        {
            epochTime.OffsetMilliseconds = database.GetServerTimeOffsetMillis() ?? 0;
            logger.Debug("Initial time offset: " + epochTime.Offset);
            SessionDocument sessionDocument      = database.GetSessionDocument(localUser.Swid);
            long            lastNotificationTime = sessionDocument.LastNotificationTime;

            StateGetter.GetState(logger, epochTime, clientVersion, database, userDatabase, notificationQueue, mixWebCallFactory, localUser.Swid, lastNotificationTime, delegate(GetStateResponse response)
            {
                HandleGetStateSuccess(logger, getStateResponseParser, response, mixWebCallFactory, localUser, userDatabase, notificationPoller, callback);
            }, delegate
            {
                callback(new ResumeSessionResult(success: false));
            });
        }
コード例 #16
0
 public LegalMarketingErrorsBuilder(IRegistrationConfigurationGetter registrationConfigurationGetter, string languagePreference, IEpochTime epochTime)
 {
     this.registrationConfigurationGetter = registrationConfigurationGetter;
     this.languagePreference = languagePreference;
     this.epochTime          = epochTime;
 }