コード例 #1
0
        //--- msg readers
        private void AuthenticationSuccessMsgReader(ReceivedMsg receivedMsg, AuthenticationSuccesMessage msg)
        {
            _authenticationState.Stem1_MsgReader(receivedMsg, msg);

            if (_authenticationState.State == UserAuthenticationState.AuthenticationState.Success)
            {
                _authenticationState = null;
                IsConnected          = true;

                if (OnUserLogin != null)
                {
                    OnUserLogin();
                }
            }
        }
コード例 #2
0
        public void MainLoopFrame()
        {
            //---В главном потоке спокойно читаем события подклюбчения\отключения

            int count = 0;

            while (_eventQueue.Count > 0 && count < 100)
            {
                count++;

                ClientEvent reseivedEvent = _eventQueue.Dequeue();
                // Disconnect
                if (reseivedEvent.EventType == ClientEvent.Event.Disconnected)
                {
                    if (IsConnected)
                    {
                        IsConnected = false;
                        if (OnUserDisconnected != null)
                        {
                            OnUserDisconnected(this, new EventArgs());
                        }
                    }
                }

                // Connect
                if (reseivedEvent.EventType == ClientEvent.Event.Connected)
                {
                    IsConnected          = true;
                    _authenticationState = new UserAuthenticationState(_client, _login);
                }
            }

            // аутентийикация
            if (_authenticationState != null)
            {
                if (_authenticationState.State == UserAuthenticationState.AuthenticationState.Fail)
                {
                    _authenticationState = null;
                }
            }

            _msgQueue.ReadStoredMsg();
        }