示例#1
0
        public override async Task OnConnectedAsync()
        {
            var httpContext = Context.GetHttpContext();
            var otherUser   = httpContext.Request.Query["user"].ToString();
            var groupName   = GetGroupName(Context.User.GetUsername(), otherUser);
            await Groups.AddToGroupAsync(Context.ConnectionId, groupName);

            var messages = await _messageLogic.GetMessageThread(Context.User.GetUsername(), otherUser);

            await Clients.Group(groupName).SendAsync("ReceiveMessageThread", messages);

            await AddToGroup(groupName);
        }
示例#2
0
        public async Task <IActionResult> GetMessageThread(string username)
        {
            var loggedIn = User.GetUsername();

            return(Ok(await _messageLogic.GetMessageThread(loggedIn, username)));
        }