✨ Implement realtime chat
This commit is contained in:
56
DysonNetwork.Sphere/Chat/Realtime/IRealtimeService.cs
Normal file
56
DysonNetwork.Sphere/Chat/Realtime/IRealtimeService.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DysonNetwork.Sphere.Chat.Realtime;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for real-time communication services (like Cloudflare, Agora, Twilio, etc.)
|
||||
/// </summary>
|
||||
public interface IRealtimeService
|
||||
{
|
||||
/// <summary>
|
||||
/// Service provider name
|
||||
/// </summary>
|
||||
string ProviderName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new real-time session
|
||||
/// </summary>
|
||||
/// <param name="roomId">The room identifier</param>
|
||||
/// <param name="metadata">Additional metadata to associate with the session</param>
|
||||
/// <returns>Session configuration data</returns>
|
||||
Task<RealtimeSessionConfig> CreateSessionAsync(Guid roomId, Dictionary<string, object> metadata);
|
||||
|
||||
/// <summary>
|
||||
/// Ends an existing real-time session
|
||||
/// </summary>
|
||||
/// <param name="sessionId">The session identifier</param>
|
||||
/// <param name="config">The session configuration</param>
|
||||
Task EndSessionAsync(string sessionId, RealtimeSessionConfig config);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a token for user to join the session
|
||||
/// </summary>
|
||||
/// <param name="account">The user identifier</param>
|
||||
/// <param name="sessionId">The session identifier</param>
|
||||
/// <param name="isAdmin">The user is the admin of session</param>
|
||||
/// <returns>User-specific token for the session</returns>
|
||||
string GetUserToken(Account.Account account, string sessionId, bool isAdmin = false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Common configuration object for real-time sessions
|
||||
/// </summary>
|
||||
public class RealtimeSessionConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// Service-specific session identifier
|
||||
/// </summary>
|
||||
public string SessionId { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Additional provider-specific configuration parameters
|
||||
/// </summary>
|
||||
public Dictionary<string, object> Parameters { get; set; } = new();
|
||||
}
|
Reference in New Issue
Block a user