mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using NetWebSocket = System.Net.WebSockets.WebSocket;
|
|
namespace Serein.Proto.WebSocket
|
|
{
|
|
/// <summary>
|
|
/// WebSocket服务
|
|
/// </summary>
|
|
public interface ISereinWebSocketService
|
|
{
|
|
/// <summary>
|
|
/// 目前有多少个连接
|
|
/// </summary>
|
|
int ConcetionCount { get; }
|
|
|
|
/// <summary>
|
|
/// 添加处理模块
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <returns></returns>
|
|
ISereinWebSocketService AddHandleModule<T>() where T : ISocketHandleModule, new();
|
|
|
|
/// <summary>
|
|
/// 添加处理模块
|
|
/// </summary>
|
|
/// <typeparam name="T"></typeparam>
|
|
/// <param name="instanceFactory">使用指定的实例</param>
|
|
/// <returns></returns>
|
|
ISereinWebSocketService AddHandleModule<T>(Func<ISocketHandleModule> instanceFactory) where T : ISocketHandleModule;
|
|
|
|
/// <summary>
|
|
/// 跟踪未处理的异常
|
|
/// </summary>
|
|
/// <param name="onExceptionTrackingAsync"></param>
|
|
/// <returns></returns>
|
|
ISereinWebSocketService TrackUnhandledExceptions(Func<Exception, Func<object, Task>, Task> onExceptionTrackingAsync);
|
|
|
|
/// <summary>
|
|
/// 添加新的 WebSocket 连接进行处理消息
|
|
/// </summary>
|
|
/// <param name="webSocket"></param>
|
|
Task AddWebSocketHandleAsync(NetWebSocket webSocket);
|
|
|
|
/// <summary>
|
|
/// 推送消息
|
|
/// </summary>
|
|
/// <param name="latestData"></param>
|
|
/// <returns></returns>
|
|
Task PushDataAsync(object latestData);
|
|
|
|
}
|
|
}
|