Exemplo n.º 1
0
        public async Task SendMessage(string room, string user, string message, CancellationToken cancellationToken)
        {
            ChatRoom roomStruct = await chatRoomRepo.GetRoomAsync(room, cancellationToken);

            if (roomStruct == null)
            {
                // lazy create room
                roomStruct = new ChatRoom(room);
            }

            var chatMessage = new ChatMessage(user, message);

            Task dummy = chatRoomRepo.AddMessageAsync(room, chatMessage, cancellationToken);
            // no need to await for message to be sent
        }