Files
Ping/backend/Hosts/Ping.Api/Hubs/RealtimeNotifier.cs
T
Admin 0623875dfa Add Ping backend
.NET 10 solution for Ping, a Discord style chat app: Domain, Application
and Infrastructure projects plus the Api host. SignalR for chat and
presence, LiveKit for call tokens, EF Core on Postgres, S3 compatible
storage for attachments, and OIDC auth shared with the Musify Zitadel
instance. Includes the Compose stack for local development.
2026-09-21 19:32:55 +02:00

24 lines
1.4 KiB
C#

using Microsoft.AspNetCore.SignalR;
using Ping.Application.Contracts;
using Ping.Application.Messages.Responses;
namespace Ping.Api.Hubs;
public sealed class RealtimeNotifier(IHubContext<ChatHub> hubContext) : IRealtimeNotifier
{
public Task MessageCreatedAsync(Guid channelId, MessageResponse message, CancellationToken cancellationToken) =>
hubContext.Clients.Group(ChatHub.GroupName(channelId)).SendAsync("MessageCreated", message, cancellationToken);
public Task MessageUpdatedAsync(Guid channelId, MessageResponse message, CancellationToken cancellationToken) =>
hubContext.Clients.Group(ChatHub.GroupName(channelId)).SendAsync("MessageUpdated", message, cancellationToken);
public Task MessageDeletedAsync(Guid channelId, Guid messageId, CancellationToken cancellationToken) =>
hubContext.Clients.Group(ChatHub.GroupName(channelId)).SendAsync("MessageDeleted", messageId, cancellationToken);
public Task FriendRequestReceivedAsync(long addresseeId, Guid friendshipId, CancellationToken cancellationToken) =>
hubContext.Clients.User(addresseeId.ToString()).SendAsync("FriendRequestReceived", friendshipId, cancellationToken);
public Task FriendshipUpdatedAsync(long userId, Guid friendshipId, CancellationToken cancellationToken) =>
hubContext.Clients.User(userId.ToString()).SendAsync("FriendshipUpdated", friendshipId, cancellationToken);
}