コード例 #1
0
        private async Task SendDialogMessagesReadedNoticeAsync(IEnumerable <Guid> messagesId, long dialogId, long senderId)
        {
            var clients = connectionsService.GetUserClientConnections(senderId);

            if (clients != null)
            {
                MessagesReadedNotice notice = new MessagesReadedNotice(messagesId, ConversationType.Dialog, dialogId);
                await SendNoticeToClientsAsync(clients, notice).ConfigureAwait(false);
            }
        }
コード例 #2
0
        private async Task SendChannelMessagesReadedNoticeAsync(IEnumerable <Guid> readedMessagesId, long channelId, long userId, ClientConnection clientConnection)
        {
            MessagesReadedNotice notice = new MessagesReadedNotice(readedMessagesId, ConversationType.Channel, channelId);
            var clientConnections       = connectionsService.GetUserClientConnections(userId);

            if (clientConnections != null)
            {
                await SendNoticeToClientsAsync(clientConnections.Where(opt => opt != clientConnection), notice).ConfigureAwait(false);
            }
        }
コード例 #3
0
        private async Task SendChatMessagesReadedNoticeAsync(IEnumerable <MessageDto> messages, long chatId, long requestorId)
        {
            List <ChatUserDto> chatUsers = await loadChatsService.GetChatUsersAsync(messages.Select(message => message.SenderId.GetValueOrDefault()).Append(requestorId), chatId).ConfigureAwait(false);

            ChatUserDto requestorChatUser = chatUsers.FirstOrDefault(chatUser => chatUser.UserId == requestorId);

            foreach (var groupBySender in messages.GroupBy(message => message.SenderId))
            {
                var clients = connectionsService.GetUserClientConnections(groupBySender.Key.GetValueOrDefault());
                if (clients != null && requestorId != groupBySender.Key)
                {
                    if (groupBySender.Any())
                    {
                        MessagesReadedNotice notice = new MessagesReadedNotice(
                            groupBySender.Select(opt => opt.GlobalId),
                            ConversationType.Chat,
                            chatId);
                        await SendNoticeToClientsAsync(clients, notice).ConfigureAwait(false);
                    }
                }
            }
        }