示例#1
0
        public async Task SendMessage(AddPrivateMessageDto message)
        {
            var connectionId = Context.ConnectionId;
            var from         = _userManager.GetUserById(connectionId);

            message.From = from.Login;
            var addedMessage = await _messageService.AddMessage(message);

            var receiver       = _userManager.GetUserByLogin(message.To);
            var toConnectionId = string.Empty;

            if (receiver != null)
            {
                toConnectionId = receiver.ConnectionId;
            }

            await Clients.Clients(toConnectionId, connectionId).MessageAdded(addedMessage);
        }