Exemple #1
0
        public static bool Start()
        {
            if (_isRunning)
            {
                return(true);
            }

            _isRunning = true;

            if (_server == null)
            {
                _server = new WebSocket_Server();
                _server.MessageReceived += Server_MessageReceived;
                _server.DataReceived    += Server_DataReceived;
                _server.NewConnected    += Server_NewConnected;
                _server.Closed          += Server_Closed;
            }

            var result = _server.Start(Utils.setting.WebSocketServerPort, "Ritsukage WebSocket Server");

            if (result)
            {
                Common.AppData.CQLog.Info("WebSocket Server", $"Start at port {Utils.setting.WebSocketServerPort}");
            }
            return(result);
        }
Exemple #2
0
        public static void Stop()
        {
            if (!_isRunning)
            {
                return;
            }

            Common.AppData.CQLog.Info("WebSocket Server", "Close");

            _server?.Dispose();
            _server    = null;
            _isRunning = false;
        }