예제 #1
0
 public async Task <bool> Add([FromBody] Chat chat)
 {
     if (await chatService.Add(chat) != null)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
    public override async Task OnConnectedAsync()
    {
        Context.GetHttpContext().Request.Query.TryGetValue("name", out var name);

        var client = new Client(Context.ConnectionId, name);

        _chatService.Add(client);

        await Clients.All.SendAsync("Connected", client);

        var clients = _chatService.GetExcept(Context.ConnectionId);

        await Clients.Client(Context.ConnectionId).SendAsync("Listed", clients);

        await base.OnConnectedAsync();
    }
예제 #3
0
 public async Task AddMessage(MessageHistory messageHistory)
 {
     await _chatRepository.Add(messageHistory);
 }