Module: EventMachine::JsonRPC

Defined in:
lib/em-jsonrpc/version.rb,
lib/em-jsonrpc/constants.rb,
lib/em-jsonrpc/server.rb,
lib/em-jsonrpc/client.rb

Defined Under Namespace

Classes: Client, ConnectionError, Server

Constant Summary collapse

VERSION =
"0.0.3"
CODE_INVALID_JSON =
-32700
MSG_INVALID_JSON =
"invalid JSON"
CODE_INVALID_REQUEST =
-32600
MSG_INVALID_REQ_JSONRPC =
"invalid request: doesn't include \"jsonrpc\": \"2.0\""
MSG_INVALID_REQ_ID =
"invalid request: wrong id"
MSG_INVALID_REQ_METHOD =
"invalid request: wrong method"
MSG_INVALID_REQ_PARAMS =
"invalid request: wrong params"
CODE_METHOD_NOT_FOUND =
-32601
MSG_METHOD_NOT_FOUND =
"method not found"
CODE_INVALID_PARAMS =
-32602
MSG_INVALID_PARAMS =
"invalid parameter(s)"
CODE_INTERNAL_ERROR =
-32603
MSG_INTERNAL_ERROR =
"internal error"
PARSING_ERROR_RESPONSE =
"{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{" \
"\"code\":#{CODE_INVALID_JSON}," \
"\"message\":\"#{MSG_INVALID_JSON}\"}}"
BATCH_NOT_SUPPORTED_RESPONSE =
"{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{" \
"\"code\":-32099," \
"\"message\":\"batch mode not implemented\"}}"
KEY_JSONRPC =
"jsonrpc"
VALUE_VERSION =
"2.0"
KEY_ID =
"id"
KEY_METHOD =
"method"
KEY_PARAMS =
"params"
KEY_RESULT =
"result"
KEY_ERROR =
"error"
KEY_CODE =
"code"
KEY_MESSAGE =
"message"

Class Method Summary collapse

Class Method Details

.connect_tcp(host, port, handler, request_timeout = nil, parser_options = {}, &block) ⇒ Object

Raises:

  • (Error)


199
200
201
202
203
# File 'lib/em-jsonrpc/client.rb', line 199

def self.connect_tcp(host, port, handler, request_timeout=nil, parser_options={}, &block)
  raise Error, "EventMachine is not running" unless EM.reactor_running?

  EM.connect(host, port, handler, host, port, request_timeout, parser_options, &block)
end

.start_tcp_server(addr, port, handler, options = nil, &block) ⇒ Object

Raises:

  • (Error)


205
206
207
208
# File 'lib/em-jsonrpc/server.rb', line 205

def self.start_tcp_server(addr, port, handler, options=nil, &block)
  raise Error, "EventMachine is not running" unless EM.reactor_running?
  EM.start_server addr, port, handler, options, &block
end

.start_unix_domain_server(filename, handler, options = nil, &block) ⇒ Object

Raises:

  • (Error)


210
211
212
213
# File 'lib/em-jsonrpc/server.rb', line 210

def self.start_unix_domain_server(filename, handler, options=nil, &block)
  raise Error, "EventMachine is not running" unless EM.reactor_running?
  EM.start_unix_domain_server filename, handler, options, &block
end