private function can($response, $error) {

        $encoded = null;

        if ( $this->protocol == 'xml' ) {

            $encoder = new XmlrpcEncoder();

            $encoder->setEncoding($this->encoding);

            try {

                $encoded = $error ? $encoder->encodeError($response->getCode(), $response->getMessage()) : $encoder->encodeResponse($response);

            } catch (XmlrpcException $xe) {

                $this->logger->error($xe->getMessage());

                $encoded = $encoder->encodeError(-32500, "Application error");

            }

        } else {

            if ( strtolower($this->encoding) != 'utf-8' && !is_null($response) ) {

                array_walk_recursive($response, function(&$entry) {

                    if ( is_string($entry) ) {

                        $entry = mb_convert_encoding($entry, strtoupper($this->encoding), "UTF-8");

                    }

                });

            }

            // json will not return any RpcException; errors (in case) are handled directly by processor

            $encoded = is_null($response) ? null : json_encode($response/*, JSON_NUMERIC_CHECK*/);

        }

        $this->logger->debug("Plain response: $encoded");

        if ( $this->request_is_encrypted /* && !empty($encoded) */ ) {

            $aes = new AES();

            $aes->setKey($this->encrypt);

            $encoded = 'comodojo_encrypted_response-'.base64_encode($aes->encrypt($encoded));

            $this->logger->debug("Encrypted response: $encoded");

        }

        return $encoded;

    }
private function can($response, $error) {

        $encoded = null;

        if ( $this->protocol == 'xml' ) {

            $encoder = new XmlrpcEncoder();

            $encoder->setEncoding($this->encoding);

            try {

                $encoded = $error ? $encoder->encodeError($response->getCode(), $response->getMessage()) : $encoder->encodeResponse($response);

            } catch (XmlrpcException $xe) {

                $this->logger->error($xe->getMessage());

                $encoded = $encoder->encodeError(-32500, "Application error");

            }

        } else {

            if ( strtolower($this->encoding) != 'utf-8' && !is_null($response) ) {

                array_walk_recursive($response, function(&$entry) {

                    if ( is_string($entry) ) {

                        $entry = mb_convert_encoding($entry, strtoupper($this->encoding), "UTF-8");

                    }

                });

            }

            // json will not return any RpcException; errors (in case) are handled directly by processor

            $encoded = is_null($response) ? null : json_encode($response/*, JSON_NUMERIC_CHECK*/);

        }

        $this->logger->debug("Plain response: $encoded");

        if ( $this->request_is_encrypted /* && !empty($encoded) */ ) {

            $aes = new AES();

            $aes->setKey($this->encrypt);

            $encoded = 'comodojo_encrypted_response-'.base64_encode($aes->encrypt($encoded));

            $this->logger->debug("Encrypted response: $encoded");

        }

        return $encoded;

    }
private function can ( $ response , $ error ) { $ encoded = null ; if ( $ this -> protocol == 'xml' ) { $ encoder = new XmlrpcEncoder ( ) ; $ encoder -> setEncoding ( $ this -> encoding ) ; try { $ encoded = $ error ? $ encoder -> encodeError ( $ response -> getCode ( ) , $ response -> getMessage ( ) ) : $ encoder -> encodeResponse ( $ response ) ; } catch ( XmlrpcException $ xe ) { $ this -> logger -> error ( $ xe -> getMessage ( ) ) ; $ encoded = $ encoder -> encodeError ( - 32500 , "Application error" ) ; } } else { if ( strtolower ( $ this -> encoding ) != 'utf-8' && ! is_null ( $ response ) ) { array_walk_recursive ( $ response , function ( & $ entry ) { if ( is_string ( $ entry ) ) { $ entry = mb_convert_encoding ( $ entry , strtoupper ( $ this -> encoding ) , "UTF-8" ) ; } } ) ; } // json will not return any RpcException; errors (in case) are handled directly by processor $ encoded = is_null ( $ response ) ? null : json_encode ( $ response /*, JSON_NUMERIC_CHECK*/ ) ; } $ this -> logger -> debug ( "Plain response: $encoded" ) ; if ( $ this -> request_is_encrypted /* && !empty($encoded) */ ) { $ aes = new AES ( ) ; $ aes -> setKey ( $ this -> encrypt ) ; $ encoded = 'comodojo_encrypted_response-' . base64_encode ( $ aes -> encrypt ( $ encoded ) ) ; $ this -> logger -> debug ( "Encrypted response: $encoded" ) ; } return $ encoded ; }
Can the RPC response

@param mixed   $response
@param boolean $error

@return string
@throws RpcException
Can the RPC response