mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-08 00:46:34 +08:00
重新设计了Libray.Json Api以及 WebSocket 的交互处理方式
This commit is contained in:
55
Serein.Proto.WebSocket/ISereinWebSocketService.cs
Normal file
55
Serein.Proto.WebSocket/ISereinWebSocketService.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user