Class: MessagePack::RPC::Server
- Inherits:
-
SessionPool
- Object
- SessionPool
- MessagePack::RPC::Server
- Defined in:
- lib/msgpack/rpc/server.rb
Overview
Server is usable for RPC server. Note that Server is a SessionPool.
Defined Under Namespace
Classes: Base
Instance Attribute Summary
Attributes included from LoopUtil
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(arg1 = nil, arg2 = nil) ⇒ Server
constructor
1.
-
#listen(arg1, arg2 = nil, arg3 = nil, arg4 = nil) ⇒ Object
1.
-
#on_notify(method, param) ⇒ Object
from ServerTransport.
-
#on_request(sendable, msgid, method, param) ⇒ Object
from ServerTransport.
-
#serve(obj, accept = obj.public_methods) ⇒ Object
1.
Methods inherited from SessionPool
Methods included from LoopUtil
#run, #start_timer, #stop, #submit
Constructor Details
#initialize(arg1 = nil, arg2 = nil) ⇒ Server
-
initialize(builder, loop = Loop.new)
-
initialize(loop = Loop.new)
27 28 29 30 31 |
# File 'lib/msgpack/rpc/server.rb', line 27 def initialize(arg1=nil, arg2=nil) super(arg1, arg2) @dispatcher = nil @listeners = [] end |
Instance Method Details
#close ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/msgpack/rpc/server.rb', line 70 def close @listeners.reject! {|listener| listener.close true } super end |
#listen(arg1, arg2 = nil, arg3 = nil, arg4 = nil) ⇒ Object
-
listen(listener, obj = nil, accept = obj.public_methods)
-
listen(host, port, obj = nil, accept = obj.public_methods)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/msgpack/rpc/server.rb', line 48 def listen(arg1, arg2 = nil, arg3 = nil, arg4 = nil) if arg1.respond_to?(:listen) # 1. listener = arg1 obj = arg2 accept = arg3 || obj.public_methods else # 2. listener = TCPServerTransport.new(Address.new(arg1,arg2)) obj = arg3 accept = arg4 || obj.public_methods end unless obj.nil? serve(obj, accept) end listener.listen(self) @listeners.push(listener) nil end |
#on_notify(method, param) ⇒ Object
from ServerTransport
85 86 87 88 |
# File 'lib/msgpack/rpc/server.rb', line 85 def on_notify(method, param) #:nodoc: responder = NullResponder.new dispatch_method(method, param, responder) end |
#on_request(sendable, msgid, method, param) ⇒ Object
from ServerTransport
79 80 81 82 |
# File 'lib/msgpack/rpc/server.rb', line 79 def on_request(sendable, msgid, method, param) #:nodoc: responder = Responder.new(sendable, msgid) dispatch_method(method, param, responder) end |
#serve(obj, accept = obj.public_methods) ⇒ Object
-
serve(dispatcher)
-
serve(obj, accept = obj.public_methods)
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/msgpack/rpc/server.rb', line 35 def serve(obj, accept = obj.public_methods) if obj.is_a?(Dispatcher) # 2. @dispatcher = obj else # 1. @dispatcher = ObjectDispatcher.new(obj, accept) end self end |