Class: EZMQ::Server
Overview
Reply socket that listens for and replies to requests.
Instance Attribute Summary (collapse)
-
- (Object) provides
Returns the value of attribute provides.
Attributes inherited from Socket
#context, #decode, #encode, #socket
Instance Method Summary (collapse)
-
- (Server) initialize(provides: -> m { m }, **options)
constructor
Creates a new Server socket.
-
- (void) listen(handler: -> { send @provides.call(receive) })
By default, waits to receive a message, calls @action with it, replies with the result, then loops.
Methods inherited from Socket
#bind, #connect, #receive, #send
Constructor Details
- (Server) initialize(provides: -> m { m }, **options)
Creates a new Server socket.
98 99 100 101 |
# File 'lib/ezmq.rb', line 98 def initialize(provides: -> m { m }, **) @provides = provides super :bind, ZMQ::REP, end |
Instance Attribute Details
- (Object) provides
Returns the value of attribute provides
87 88 89 |
# File 'lib/ezmq.rb', line 87 def provides @provides end |
Instance Method Details
- (void) listen(handler: -> { send @provides.call(receive) })
This method returns an undefined value.
By default, waits to receive a message, calls @action with it, replies with the result, then loops.
110 111 112 |
# File 'lib/ezmq.rb', line 110 def listen(handler: -> { send @provides.call(receive) }) loop { handler.call } end |