Exemplo n.º 1
0
 public void OnRegistrationState(RegistrationStateChanged e)
 {
     Account account = null;
     lock (_lock)
         if (_accounts.ContainsKey(e.Id) && _accounts[e.Id] != null)
             account = (Account) _accounts[e.Id];
     if (account != null) account.HandleStateChanged();
 }
Exemplo n.º 2
0
        public void OnRegistrationState(RegistrationStateChanged e)
        {
            Account account = null;

            lock (_lock)
                if (_accounts.ContainsKey(e.Id) && _accounts[e.Id] != null)
                {
                    account = (Account)_accounts[e.Id];
                }
            if (account != null)
            {
                account.HandleStateChanged();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when registration state changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PushModel_StateChanged(object sender, PushConnectionStateEventArgs e)
        {
            Log.Debug(Tag, $"Push State: [{e.State}], Error String: [{e.Error}]");

            State newState = State.Unregistered;

            if (e.State == PushConnectionStateEventArgs.PushState.Registered)
            {
                newState = State.Registered;

                // Get the registration id
                string id = PushClient.GetRegistrationId();
                Log.Debug(Tag, $"RegId: [{id}]");

                // If the application successfully connects with the push service,
                // it must request the unread notification messages
                // which are sent during the disconnected state
                // handlerNotification method is called if there are unread notifications
                PushClient.GetUnreadNotifications();
            }
            else if (e.State == PushConnectionStateEventArgs.PushState.Unregistered)
            {
                newState = State.Unregistered;

                Log.Debug(Tag, "Call PushServiceRegister()");

                // Send a registration request to the push service
                Task <ServerResponse> registerTask = PushClient.PushServerRegister();
                registerTask.GetAwaiter().OnCompleted(() =>
                {
                    // You will get result for register API
                    ServerResponse res = registerTask.Result;
                    Log.Debug(Tag, $"ServerResult: [{res.ServerResult}], ServerMessage: [{res.ServerMessage}]");
                });
            }

            RegistrationStateChanged?.Invoke(this, new RegistrationStateChangedEventArgs
            {
                state = newState
            });
        }