public function getClosePayload($e, $masked = true)
    {
        $code = false;

        if ($e instanceof Exception) {
            $code = $e->getCode();
        } elseif (is_numeric($e)) {
            $code = (int)$e;
        }

        if (!$code || !key_exists($code, self::CLOSE_REASONS)) {
            $code = self::CLOSE_UNEXPECTED;
        }

        $body = pack('n', $code) . self::CLOSE_REASONS[$code];

        $payload = $this->getPayload();
        return $payload->encode($body, self::TYPE_CLOSE, $masked);
    }
public function getClosePayload($e, $masked = true)
    {
        $code = false;

        if ($e instanceof Exception) {
            $code = $e->getCode();
        } elseif (is_numeric($e)) {
            $code = (int)$e;
        }

        if (!$code || !key_exists($code, self::CLOSE_REASONS)) {
            $code = self::CLOSE_UNEXPECTED;
        }

        $body = pack('n', $code) . self::CLOSE_REASONS[$code];

        $payload = $this->getPayload();
        return $payload->encode($body, self::TYPE_CLOSE, $masked);
    }
public function getClosePayload ( $ e , $ masked = true ) { $ code = false ; if ( $ e instanceof Exception ) { $ code = $ e -> getCode ( ) ; } elseif ( is_numeric ( $ e ) ) { $ code = ( int ) $ e ; } if ( ! $ code || ! key_exists ( $ code , self :: CLOSE_REASONS ) ) { $ code = self :: CLOSE_UNEXPECTED ; } $ body = pack ( 'n' , $ code ) . self :: CLOSE_REASONS [ $ code ] ; $ payload = $ this -> getPayload ( ) ; return $ payload -> encode ( $ body , self :: TYPE_CLOSE , $ masked ) ; }
Gets a suitable WebSocket close frame.
Please set `masked` to false if you send a close frame from server side.

@param Exception|int $e
@param boolean       $masked
@return Payload
Gets a suitable WebSocket close frame . Please set masked to false if you send a close frame from server side .