public void Logout()
 {
     _store.SetSession(null);
     currentSession = null;
     OnLogout?.Invoke(this, EventArgs.Empty);
     SessionChanged?.Invoke(this, EventArgs.Empty);
 }
Exemple #2
0
        public void SetSession(Session session)
        {
            if (session == CurrentSession)
            {
                return;
            }

            SessionChanged?.Invoke(this, session);

            Content.Reset(); // clear all fragments & chunks cache

            if (CurrentSession != null)
            {
                CurrentSession.Storage.BlockIterator.ClearCache();
                CurrentSession.StorageDataChanged -= StorageDataChanged;;
                CurrentSession.ViewContent         = Content; // backup state
            }

            CurrentSession = session;
            CurrentSession.StorageDataChanged += StorageDataChanged;

            if (CurrentSession.ViewContent is FragmentViewContent viewContent)
            {
                Content = viewContent; // restore state
            }
            else
            {
                CreateContent(); // new session
            }

            Mouse.IsSelecting = false; // reset ongoing selection

            InvalidateMeasure();       // rebuild all fragments
        }
Exemple #3
0
        protected override void Consume([NotNull] SessionChangedEvent @event)
        {
            if (@event == null)
            {
                throw new ArgumentNullException(nameof(@event));
            }

            SessionChanged?.Invoke(this, @event.SessionId);
        }
Exemple #4
0
        public void AddIncomingLetter(Letter letter)
        {
            var dialog = GetDialogById(letter.FromId);

            if (dialog != null)
            {
                dialog.Chat += "<< " + letter.Message + "\n";
                SessionChanged?.Invoke(Dialogs);
            }
        }
Exemple #5
0
        public void AddOutgoingLetter(Letter letter) // TODO: почти одинаковый метод с AddIncomingLetter!
        {
            var dialog = GetDialogById(letter.ToId);

            if (dialog != null)
            {
                dialog.Chat += ">> " + letter.Message + "\n";
                SessionChanged?.Invoke(Dialogs);
            }
        }
        public void SetCurrentSession(IApi api)
        {
            ;
            currentSession = api;
            if (api != null)
            {
                _store.SetSession(api.GetSessionInfo());
            }

            SessionChanged?.Invoke(this, EventArgs.Empty);
            OnLogin?.Invoke(this, EventArgs.Empty);
            SessionChanged?.Invoke(this, EventArgs.Empty);
        }
Exemple #7
0
        public virtual void Attach(ConsoleSession session)
        {
            if (session == Session)
            {
                return;
            }
            var oldSession = Session;

            Session = null;
            oldSession?.RemoveClient(this);
            this.Session = session;
            Session?.AddClient(this);
            SessionChanged?.Invoke(this);
        }
Exemple #8
0
        public void HandleNetworkEven(UserNetworkEvent netEvent)
        {
            switch (netEvent.NetworkEvent)
            {
            case NetworkEvent.Connect:
                TryCreateNewDialog(netEvent.Id, netEvent.Name);
                break;

            case NetworkEvent.Leave:
                RemoveDialog(netEvent.Id);
                break;
            }

            SessionChanged?.Invoke(Dialogs);
        }
Exemple #9
0
        /// <summary>
        /// Called by UnityEngine when a broadcast is received.
        /// </summary>
        /// <param name="fromAddress">When the broadcast came from</param>
        /// <param name="data">The data in the broad cast. Not currently used, but could
        /// be used for differentiating rooms or similar.</param>
        public void receivedBroadcast(string fromAddress, string data)
        {
            Debug.Log(fromAddress);
            Debug.Log(data);
            string serverIp = fromAddress.Substring(fromAddress.LastIndexOf(':') + 1);

            sessions_ = new SessionInfo()
            {
                ip = serverIp, name = data
            };

            if (SessionChanged != null)
            {
                SessionChanged.Invoke();
            }
        }
Exemple #10
0
 public void DestroySession(String sessionID)
 {
     try
     {
         lock (rfcThreads)
         {
             if (rfcThreads.Remove(sessionID))
             {
                 // Send the event to the RfcSessionManager:
                 SessionChanged?.Invoke(new RfcSessionEventArgs(RfcSessionManager.EventType.DESTROYED, sessionID));
             }
         }
     }
     catch (Exception ex)
     {
         //My.Application.Log.WriteException(ex);
     }
 }
Exemple #11
0
        private void OnSessionNotify(ICallSession session)
        {
            SessionChanged?.Invoke(session);

            switch (session.State)
            {
            case CallState.Idle:
                session.Notify -= OnSessionNotify;
                try
                {
                    _sessions.TryRemove(session.Id, out _);
                    _container.Release(session.RouteId);
                }
                finally
                {
                    session.Dispose();
                }
                break;

            default:
                break;
            }
        }
Exemple #12
0
 protected void OnSessionChanged(object data)
 {
     SessionChanged?.Invoke(this, new SessionStatusArgs(data));
 }
Exemple #13
0
 private void SendStateChange()
 {
     SessionChanged?.Invoke(this, new SessionEventArgs(_sessionState));
 }
Exemple #14
0
 private void OnSessionChanged(PacketReceivedEventArgs <PacketSessionData> e)
 {
     SessionChanged?.Invoke(this, e);
 }
Exemple #15
0
 private void OnSessionChanged(IEnumerable <Change> changes)
 {
     PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SessionSerialized"));
     SessionChanged?.Invoke(this, new EventArgs <IEnumerable <Change> >(changes));
 }
Exemple #16
0
 protected void OnSessionChanged(AgentSessionBase session)
 {
     SessionChanged?.Invoke(this, new SessionStateEventArgs(session));
 }
Exemple #17
0
 /// <summary>
 /// Called when the value of the <see cref="Session"/> property has changed.
 /// </summary>
 /// <remarks>
 /// When the manager is first created, the value of <see cref="Session"/>
 /// will be <see langword = "null" />. Various operations of the manager
 /// can cause sessions to be created or replaced. This event will fire
 /// whenever the value of the <see cref="Session"/> property has changed.
 /// </remarks>
 protected virtual void OnSessionChanged()
 {
     SessionChanged?.Invoke(this, EventArgs.Empty);
 }
Exemple #18
0
 public static void FireSessionChangedEvent(SessionChangedEventArgs args)
 {
     SessionChanged?.Invoke(args);
 }