public void Logout(User user, ISellTicketsClient client)
        {
            Console.WriteLine("SellTicketsServer - LogOut");

            this._loggedClients.Remove(key: user.Username);
            Console.WriteLine("SellTicketsServer - LogOut succesfuly");
        }
        public void Login(User user, ISellTicketsClient client)
        {
            Console.WriteLine("SellTicketsServer - LogIn");

            this._userService.LogIn(user.Username, user.Password);
            this._loggedClients.Add(user.Username, client);
            Console.WriteLine("SellTicketsServer - Login succesfuly");
        }
예제 #3
0
        public virtual void Logout(User user, ISellTicketsClient client)
        {
            UserDTO udto = DTOUtils.GetDTO(user);

            SendRequest(new LogoutRequest(udto));
            IResponse response = ReadResponse();

            CloseConnection();
            if (response is ErrorResponse)
            {
                ErrorResponse err = (ErrorResponse)response;
                throw new ControllerException(err.Message);
            }
        }
예제 #4
0
 private void CloseConnection()
 {
     _finished = true;
     try
     {
         _stream.Close();
         //output.close();
         _connection.Close();
         _waitHandle.Close();
         _client = null;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.StackTrace);
     }
 }
예제 #5
0
        public virtual void Login(User user, ISellTicketsClient client)
        {
            InitializeConnection();
            var udto = DTOUtils.GetDTO(user);

            SendRequest(new LoginRequest(udto));
            var response = ReadResponse();

            if (response is OkResponse)
            {
                this._client = client;
                return;
            }
            else if (response is ErrorResponse)
            {
                var err = (ErrorResponse)response;
                CloseConnection();
                throw new ControllerException(err.Message);
            }
        }