MethodResponse

NAME

Cro::RPC::JSON::MethodResponse ā€“ container for method response

DESCRIPTION

This class is a mediator between JSON-RPC actor code and the connected client. Normally it's only useful for asynchronous mode of operation (see Cro::JSON::RPC). And even then it's better be created using Cro::RPC::JSON::Request response method.

An instance of this class can be either in incomplete or completed state. The latter means that it has either $.result or $.error attribute set. Setting both of them is considered a error and X::Cro::RPC::JSON::ServerError is thrown then.

Batches

If Cro::RPC::JSON::MethodResponse belongs to batch response it reports back to the batch object of Cro::RPC::JSON::BatchResponse when gets completed.

Class Error

Cro::RPC::JSON::MethodResponse::Error class is used by this module internally to hold and convert into a JSON object information about errors.

ATTRIBUTES

  • $.result - contains the result of calling a JSON-RPC method. Could be any JSONifiable object

  • $.error ā€“ an instance of Cro::RPC::JSON::MethodResponse::Error

  • $.jrpc-request - Cro::RPC::JSON request object to which this response is generated

Class Error Attributes

  • $.code - one of JSON-RPC error codes.

  • Str $.message ā€“ a message explaining the error

  • %.data - additional data related to the error. Method set-error sets this to a hash with two keys: exception and backtrace of the exception.

METHODS

filled()

Returns True if response is complete.

proto set-error(|)

Sets $.error either from a hash or from a X::Cro::RPC::JSON exception.

set-result($data)

Sets $.result to $data.

Hash

Returns a hash ready for JSONifying and returning back to the client.

Class Error Methods

set-data(%data)

Sets Error's $.data.

Hash

Returns a hash ready to be used as JSON-RPC object error key value.

SEE ALSO

Cro, Cro::RPC::JSON, Cro::RPC::JSON::Request, Cro::RPC::JSON::BatchResponse

AUTHOR

Vadim Belman [email protected]

LICENSE

Artistic License 2.0

See the LICENSE file in this distribution.

Cro::RPC::JSON v0.1.5

JSON-RPC 2.0 framework built on top of Cro

Authors

  • Vadim Belman

License

Artistic-2.0

Dependencies

Cro::HTTPJSON::FastJSON::MarshalCro::HTTP::RouterCro::HTTP::Router::WebSocket

Provides

  • Cro::RPC::JSON
  • Cro::RPC::JSON::Auth
  • Cro::RPC::JSON::BatchRequest
  • Cro::RPC::JSON::BatchResponse
  • Cro::RPC::JSON::Exception
  • Cro::RPC::JSON::Handler
  • Cro::RPC::JSON::META
  • Cro::RPC::JSON::Message
  • Cro::RPC::JSON::Metamodel::ClassHOW
  • Cro::RPC::JSON::Metamodel::ConcreteRoleHOW
  • Cro::RPC::JSON::Metamodel::MethodContainer
  • Cro::RPC::JSON::Metamodel::ParametricRoleHOW
  • Cro::RPC::JSON::Method
  • Cro::RPC::JSON::MethodResponse
  • Cro::RPC::JSON::Notification
  • Cro::RPC::JSON::Request
  • Cro::RPC::JSON::RequestParser
  • Cro::RPC::JSON::RequestParser::BodyStr
  • Cro::RPC::JSON::RequestParser::HTTP
  • Cro::RPC::JSON::RequestParser::WebSocket
  • Cro::RPC::JSON::Requestish
  • Cro::RPC::JSON::Response
  • Cro::RPC::JSON::ResponseSerializer
  • Cro::RPC::JSON::ResponseSerializer::HTTP
  • Cro::RPC::JSON::ResponseSerializer::WebSocket
  • Cro::RPC::JSON::Transform
  • Cro::RPC::JSON::Unmarshal
  • Cro::RPC::JSON::Utils

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.