Exemplo n.º 1
0
        public void ConnectToServer(EventConnectToServer connectionEvent)
        {
            ConnectionStatusChanged("Connecting to server.");

            if (orgasmHandler.Connect(connectionEvent.Host))
            {
                ConnectionStatusChanged("Connected. Validating credentials.");

                if (orgasmHandler.Authenticate(connectionEvent.Username, connectionEvent.Password))
                {
                    ConnectionStatusChanged(string.Format("Welcome {0}!", connectionEvent.Username));
                    ConnectToServerSuccess();
                }
                else
                {
                    ConnectionStatusChanged("Supplied credentials are not valid.");
                    ConnectToServerFailed();
                }
            }
            else
            {
                ConnectionStatusChanged("Failed to connect to server.");
                ConnectToServerFailed();
            }
        }
Exemplo n.º 2
0
        public void Login(string host, string username, string password)
        {
            if (host.IsNullOrWhiteSpace())
            {
                throw new ControllerException(LoginExceptions.NoHostSupplied);
            }
            if (username.IsNullOrWhiteSpace() || password.IsNullOrWhiteSpace())
            {
                throw new ControllerException(LoginExceptions.NoUsernamePasswordSupplied);
            }

            var connectEvent = new EventConnectToServer();

            connectEvent.Host     = host.Trim();
            connectEvent.Username = username.Trim();
            connectEvent.Password = password.Trim();
            connectEvent.PostWorkerThread();
        }