C#C
C#9mo ago
zos

How to save signalR chat messages to database

    public async Task SendChannelMessage(string channelId, string content, List<IFormFile> attachments = null)
    {
        var authorId = Context.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
        var result = await messageRepository.CreateChannelMessageAsync(authorId, channelId, content, attachments);

        if (!result.Success)
        {
            await Clients.User(authorId).SendAsync("UploadError", result.Message);
            return;
        }

        await Clients.Group(channelId).SendAsync("ReceiveChannelMessage", content);
    }


the method CreateChannelMessageAsync just add the message to the database, but somehow when I call it from my FE project, it just skip through it. Any help is strongly appreciated!
Was this page helpful?