You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
953 B
28 lines
953 B
3 months ago
|
using System.Threading.Channels;
|
||
|
|
||
|
namespace CellularManagement.Application.Pipeline;
|
||
|
|
||
|
public interface IWebSocketMessageHandler
|
||
|
{
|
||
|
string HandlerName { get; }
|
||
|
int Priority { get; }
|
||
|
bool CanHandle(string messageType);
|
||
|
Task HandleAsync(WebSocketMessageContext context, CancellationToken cancellationToken);
|
||
|
}
|
||
|
|
||
|
public class WebSocketMessageContext
|
||
|
{
|
||
|
public string ConnectionId { get; set; } = string.Empty;
|
||
|
public string MessageType { get; set; } = string.Empty;
|
||
|
public byte[] Payload { get; set; } = Array.Empty<byte>();
|
||
|
public Dictionary<string, object> Properties { get; } = new();
|
||
|
public bool IsHandled { get; set; }
|
||
|
public Exception? Error { get; set; }
|
||
|
}
|
||
|
|
||
|
public interface IWebSocketMessagePipeline
|
||
|
{
|
||
|
Task ProcessMessageAsync(WebSocketMessageContext context, CancellationToken cancellationToken);
|
||
|
void RegisterHandler(IWebSocketMessageHandler handler);
|
||
|
void UnregisterHandler(string handlerName);
|
||
|
}
|