63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
namespace WcsMain.WebSocket;
|
|
|
|
public class WebSocketOperation
|
|
{
|
|
|
|
//private static WebSocketOperation? _instance;
|
|
|
|
//public static WebSocketOperation Instance() => _instance ??= new WebSocketOperation();
|
|
|
|
|
|
//private string websocketServe => DataService.DataBaseData.Instance().GetConfig("webSocketAddress") ?? "";
|
|
|
|
//private List<IWebSocketConnection> _connection = [];
|
|
|
|
//public void OpenWebSocket()
|
|
//{
|
|
// if (string.IsNullOrEmpty(websocketServe))
|
|
// {
|
|
// return;
|
|
// }
|
|
// CommonTool.Websocket = new WebSocketServer(websocketServe)
|
|
// {
|
|
// RestartAfterListenError = true
|
|
// };
|
|
|
|
// CommonTool.Websocket.Start(serve =>
|
|
// {
|
|
// serve.OnError += obj =>
|
|
// {
|
|
// ConsoleLog.Error($"websocket 发生异常,{obj}");
|
|
// };
|
|
// serve.OnOpen += () =>
|
|
// {
|
|
// _connection.Add(serve);
|
|
// ConsoleLog.Info($"webSocket 已经连接,在:{serve.ConnectionInfo.ClientIpAddress}");
|
|
// };
|
|
// serve.OnMessage += _ =>
|
|
// {
|
|
// // 收到消息
|
|
// };
|
|
// serve.OnClose += () =>
|
|
// {
|
|
// _connection.Remove(serve);
|
|
// ConsoleLog.Info($"webSocket 已经断开,在:{serve.ConnectionInfo.ClientIpAddress}");
|
|
// };
|
|
|
|
// });
|
|
//}
|
|
|
|
|
|
|
|
//public void Send(string msg)
|
|
//{
|
|
// if (_connection.Count < 1)
|
|
// {
|
|
// return;
|
|
// }
|
|
// foreach (var con in _connection)
|
|
// {
|
|
// con.Send(msg);
|
|
// }
|
|
//}
|
|
} |