Esempio n. 1
0
        internal void Stop(byte[] data, bool send)
        {
            PayloadData    payload = new PayloadData(data);
            CloseEventArgs args    = new CloseEventArgs(payload);

            byte[] frame = (!send) ? null : WsFrame.CreateCloseFrame(Mask.Unmask, payload).ToByteArray();
            this.Stop(args, frame);
        }
        internal void Stop(byte [] data, bool send)
        {
            var payload      = new PayloadData(data);
            var args         = new CloseEventArgs(payload);
            var frameAsBytes = send
                       ? WsFrame.CreateCloseFrame(Mask.UNMASK, payload).ToByteArray()
                       : null;

            Stop(args, frameAsBytes);
        }
        internal void Stop(byte[] data, bool send)
        {
            object sync = this._sync;

            lock (sync)
            {
                this._state = ServerState.ShuttingDown;
                PayloadData    payload = new PayloadData(data);
                CloseEventArgs args    = new CloseEventArgs(payload);
                byte[]         frame   = (!send) ? null : WsFrame.CreateCloseFrame(Mask.Unmask, payload).ToByteArray();
                foreach (WebSocketServiceHost webSocketServiceHost in this._hosts.Values)
                {
                    webSocketServiceHost.Sessions.Stop(args, frame);
                }
                this._hosts.Clear();
                this._state = ServerState.Stop;
            }
        }
        internal void Stop(byte [] data, bool send)
        {
            lock (_sync) {
                _state = ServerState.ShuttingDown;

                var payload      = new PayloadData(data);
                var args         = new CloseEventArgs(payload);
                var frameAsBytes = send
                         ? WsFrame.CreateCloseFrame(Mask.Unmask, payload).ToByteArray()
                         : null;

                foreach (var host in _hosts.Values)
                {
                    host.Sessions.Stop(args, frameAsBytes);
                }

                _hosts.Clear();
                _state = ServerState.Stop;
            }
        }