public function destroy()
    {
        // Avoid repeated calls.
        if ($this->_status === self::STATUS_CLOSED) {
            return;
        }
        // Remove event listener.
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_WRITE);

        // Close socket.
        set_error_handler(function(){});
        fclose($this->_socket);
        restore_error_handler();

        $this->_status = self::STATUS_CLOSED;
        // Try to emit onClose callback.
        if ($this->onClose) {
            try {
                call_user_func($this->onClose, $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        // Try to emit protocol::onClose
        if ($this->protocol && method_exists($this->protocol, 'onClose')) {
            try {
                call_user_func(array($this->protocol, 'onClose'), $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        $this->_sendBuffer = $this->_recvBuffer = '';
        if ($this->_status === self::STATUS_CLOSED) {
            // Cleaning up the callback to avoid memory leaks.
            $this->onMessage = $this->onClose = $this->onError = $this->onBufferFull = $this->onBufferDrain = null;
            // Remove from worker->connections.
            if ($this->worker) {
                unset($this->worker->connections[$this->_id]);
            }
            unset(static::$connections[$this->_id]);
        }
    }
public function destroy()
    {
        // Avoid repeated calls.
        if ($this->_status === self::STATUS_CLOSED) {
            return;
        }
        // Remove event listener.
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_READ);
        Worker::$globalEvent->del($this->_socket, EventInterface::EV_WRITE);

        // Close socket.
        set_error_handler(function(){});
        fclose($this->_socket);
        restore_error_handler();

        $this->_status = self::STATUS_CLOSED;
        // Try to emit onClose callback.
        if ($this->onClose) {
            try {
                call_user_func($this->onClose, $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        // Try to emit protocol::onClose
        if ($this->protocol && method_exists($this->protocol, 'onClose')) {
            try {
                call_user_func(array($this->protocol, 'onClose'), $this);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        }
        $this->_sendBuffer = $this->_recvBuffer = '';
        if ($this->_status === self::STATUS_CLOSED) {
            // Cleaning up the callback to avoid memory leaks.
            $this->onMessage = $this->onClose = $this->onError = $this->onBufferFull = $this->onBufferDrain = null;
            // Remove from worker->connections.
            if ($this->worker) {
                unset($this->worker->connections[$this->_id]);
            }
            unset(static::$connections[$this->_id]);
        }
    }
public function destroy ( ) { // Avoid repeated calls. if ( $ this -> _status === self :: STATUS_CLOSED ) { return ; } // Remove event listener. Worker :: $ globalEvent -> del ( $ this -> _socket , EventInterface :: EV_READ ) ; Worker :: $ globalEvent -> del ( $ this -> _socket , EventInterface :: EV_WRITE ) ; // Close socket. set_error_handler ( function ( ) { } ) ; fclose ( $ this -> _socket ) ; restore_error_handler ( ) ; $ this -> _status = self :: STATUS_CLOSED ; // Try to emit onClose callback. if ( $ this -> onClose ) { try { call_user_func ( $ this -> onClose , $ this ) ; } catch ( \ Exception $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } catch ( \ Error $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } } // Try to emit protocol::onClose if ( $ this -> protocol && method_exists ( $ this -> protocol , 'onClose' ) ) { try { call_user_func ( array ( $ this -> protocol , 'onClose' ) , $ this ) ; } catch ( \ Exception $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } catch ( \ Error $ e ) { Worker :: log ( $ e ) ; exit ( 250 ) ; } } $ this -> _sendBuffer = $ this -> _recvBuffer = '' ; if ( $ this -> _status === self :: STATUS_CLOSED ) { // Cleaning up the callback to avoid memory leaks. $ this -> onMessage = $ this -> onClose = $ this -> onError = $ this -> onBufferFull = $ this -> onBufferDrain = null ; // Remove from worker->connections. if ( $ this -> worker ) { unset ( $ this -> worker -> connections [ $ this -> _id ] ) ; } unset ( static :: $ connections [ $ this -> _id ] ) ; } }
Destroy connection.

@return void
Destroy connection .