Class: JsonRpcServer
- Inherits:
-
Object
- Object
- JsonRpcServer
- Includes:
- JsonRpcConstants, JsonRpcErrors
- Defined in:
- lib/jsonrpc2.0/Server.rb
Constant Summary
Constants included from JsonRpcErrors
JsonRpcErrors::ApplicationErrors, JsonRpcErrors::ImplementationErrors
Constants included from JsonRpcConstants
Instance Method Summary collapse
Methods included from JsonRpcErrors
add_application_errors, create_error_classes, error_from_hash
Instance Method Details
#handle_message(inMessage) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/jsonrpc2.0/Server.rb', line 9 def (inMessage) begin begin = JSON.parse inMessage rescue JSON::ParserError => e raise(ParseError, e.) end if .class == Array response = .map{ |e| handle_request(e) }.to_json response.compact! else response = handle_request().to_json end rescue BaseImplementationError => e id = nil id = ['id'] if (.class == Hash) error = (id) error['error'] = e response = error.to_json ensure response end end |