xiazhengtongxue
10 小时以前 af4404160a9e8d14c09f1e6acab2ba00cb7fc91b
Code/WMS/WIDESEA_WMSServer/WIDESEA_Core/Extensions/WebSocketSetup.cs
@@ -11,6 +11,22 @@
{
    public static class WebSocketSetup
    {
        //public static void AddWebSocketSetup(this IServiceCollection services)
        //{
        //    if (services == null) throw new ArgumentNullException(nameof(services));
        //    int port = AppSettings.Get("WebSocketPort").ObjToInt();
        //    if (port == 0)
        //    {
        //        port = 9296;
        //    }
        //    services.AddSingleton(x =>
        //    {
        //        WebSocketServer socketServer = new WebSocketServer();
        //        socketServer.ServerStart(port);
        //        return socketServer;
        //    });
        //}
        public static void AddWebSocketSetup(this IServiceCollection services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));
@@ -21,12 +37,11 @@
                port = 9296;
            }
            services.AddSingleton(x =>
            {
            // 直接创建并启动 WebSocket 服务器
                WebSocketServer socketServer = new WebSocketServer();
                socketServer.ServerStart(port);
                return socketServer;
            });
            services.AddSingleton(socketServer);
        }
    }
}