Example #1
0
        private void ShowAllChatsHandler(string requestInJson)
        {
            ShowAllChatsRequest          request   = JsonSerializer.Deserialize <ShowAllChatsRequest>(requestInJson);
            IReadOnlyCollection <string> chatNames = server.ChatRepository.GetChats().Select(chat => chat.Name).ToArray();

            var response = new ShowAllChatsResponse
            {
                Code      = StatusCode.Ok,
                ChatNames = chatNames,
                RequestId = request.Id
            };

            SendMessageAesEncrypted(response, ClientAesKey);
        }
Example #2
0
        private void ShowAllChatsResponseHandler(string responseInJson)
        {
            ShowAllChatsResponse response = JsonSerializer.Deserialize <ShowAllChatsResponse>(responseInJson);

            Console.WriteLine("Available chats:");

            if (response?.ChatNames == null)
            {
                return;
            }
            foreach (string chatName in response.ChatNames)
            {
                Console.WriteLine(chatName);
            }
        }