Class: MessagePack::RPC::Responder
- Inherits:
-
Object
- Object
- MessagePack::RPC::Responder
- Defined in:
- lib/msgpack/rpc/server.rb
Instance Method Summary collapse
- #error(err, retval = nil) ⇒ Object
-
#initialize(sendable, msgid) ⇒ Responder
constructor
A new instance of Responder.
- #result(retval, err = nil) ⇒ Object
- #sent? ⇒ Boolean
Constructor Details
#initialize(sendable, msgid) ⇒ Responder
Returns a new instance of Responder.
161 162 163 164 165 |
# File 'lib/msgpack/rpc/server.rb', line 161 def initialize(sendable, msgid) @sendable = sendable # send_message method is required @msgid = msgid @sent = false end |
Instance Method Details
#error(err, retval = nil) ⇒ Object
180 181 182 |
# File 'lib/msgpack/rpc/server.rb', line 180 def error(err, retval = nil) result(retval, err) end |
#result(retval, err = nil) ⇒ Object
171 172 173 174 175 176 177 178 |
# File 'lib/msgpack/rpc/server.rb', line 171 def result(retval, err = nil) unless @sent data = [RESPONSE, @msgid, err, retval].to_msgpack @sendable.send_data(data) @sent = true end nil end |
#sent? ⇒ Boolean
167 168 169 |
# File 'lib/msgpack/rpc/server.rb', line 167 def sent? @sent end |