예제 #1
0
        private async Task HandleLoginRequestAsync(Request request, TcpClient client)
        {
            var loggedUser = await m_loginHandler.ProcessAsync(client, request);

            if (!loggedUser.Equals(null) && Users.TryAdd(loggedUser.Id, client))
            {
                await CreateAndSendMessageAsync(client, loggedUser, RequestType.Login, ResponseStatus.Success, RequestContentType.Json);
            }
            else
            {
                await CreateAndSendMessageAsync(client, new { Message = "Could not login, is the user already logged?" }, RequestType.Login, ResponseStatus.Failure, RequestContentType.Text);
            }
        }