Exemple #1
0
        public void ConnectClient(Connection connection, Request request)
        {
            try
            {
                var    client = new Client(request.Username(), request.Password());
                string token  = gameLogic.Login(client);

                object[] response = string.IsNullOrEmpty(token)
                    ? BuildResponse(ResponseCode.NotFound, "Client not found. Wrong username or password.")
                    : BuildResponse(ResponseCode.Ok, token);
                connection.SendMessage(response);
            }
            catch (ClientAlreadyConnectedException e)
            {
                connection.SendMessage(BuildResponse(ResponseCode.Forbidden, e.Message));
            }
        }