Module: DDP::Server::Protocol::RPC
- Included in:
- DDP::Server::Protocol
- Defined in:
- lib/ddp/server/protocol/rpc.rb
Overview
Protocol regarding remote procedure calls
Constant Summary collapse
- NO_RESULT =
Object.new
Instance Method Summary collapse
- #handle_method(_id, _method, _params) ⇒ Object
- #handle_rpc ⇒ Object
- #send_error_result(id, error) ⇒ Object
- #send_result(id, result = NO_RESULT) ⇒ Object
- #send_updated(methods) ⇒ Object
Instance Method Details
#handle_method(_id, _method, _params) ⇒ Object
18 19 20 |
# File 'lib/ddp/server/protocol/rpc.rb', line 18 def handle_method(_id, _method, _params) raise 'Must be overridden' end |
#handle_rpc ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/ddp/server/protocol/rpc.rb', line 8 def handle_rpc case @message['msg'] when 'method' handle_method(@message['id'], @message['method'], @message['params']) true else false end end |
#send_error_result(id, error) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/ddp/server/protocol/rpc.rb', line 28 def send_error_result(id, error) = { msg: 'result', id: id } ['error'] = { error: error.class.name, reason: error., details: "Backtrace: \n#{error.backtrace.join("\n")}" } () end |
#send_result(id, result = NO_RESULT) ⇒ Object
22 23 24 25 26 |
# File 'lib/ddp/server/protocol/rpc.rb', line 22 def send_result(id, result = NO_RESULT) = { msg: 'result', id: id } ['result'] = result unless result == NO_RESULT () end |
#send_updated(methods) ⇒ Object
38 39 40 |
# File 'lib/ddp/server/protocol/rpc.rb', line 38 def send_updated(methods) msg: 'updated', methods: methods end |