示例#1
0
        static WebSockets()
        {
            CMOptions = new WebSocketsOptions();

            EventSink.ServerStarted += () => _Started = true;

            Clients = new List <WebSocketsClient>();

            OnConnected += HandleConnection;

            _ActivityTimer = PollTimer.FromSeconds(
                60.0,
                () =>
            {
                if (!_Listening || Listener == null || Listener.Server == null || !Listener.Server.IsBound)
                {
                    _Listening = false;
                    ListenAsync();
                }

                Clients.RemoveAll(c => !c.Connected);
            },
                () => CMOptions.ModuleEnabled && Clients.Count > 0);

            NetState.CreatedCallback += ns =>
            {
                if (ns is WebSocketsClient)
                {
                    var client = (WebSocketsClient)ns;

                    client.CompressionEnabled = false;
                }
            };
        }
示例#2
0
        static WebSockets()
        {
            CMOptions = new WebSocketsOptions();

            EventSink.ServerStarted += () => _Started = true;

            Clients = new List<WebSocketsClient>();

            OnConnected += HandleConnection;

            _ActivityTimer = PollTimer.FromSeconds(
                60.0,
                () =>
                {
                    if (!_Listening || Listener == null || Listener.Server == null || !Listener.Server.IsBound)
                    {
                        _Listening = false;
                        ListenAsync();
                    }

                    Clients.RemoveAll(c => !c.Connected);
                },
                () => CMOptions.ModuleEnabled && Clients.Count > 0);

            NetState.CreatedCallback += ns =>
            {
                if (ns is WebSocketsClient)
                {
                    var client = (WebSocketsClient)ns;

                    client.CompressionEnabled = false;
                }
            };
        }