Class: OMQ::SERVER
- Inherits:
-
Socket
- Object
- Socket
- OMQ::SERVER
- Includes:
- Readable, SingleFrame, Writable
- Defined in:
- lib/omq/client_server.rb
Overview
Asynchronous server socket for the CLIENT/SERVER pattern (ZeroMQ RFC 41).
Assigns a 4-byte routing ID to each connected CLIENT and supports directed replies via #send_to.
Instance Method Summary collapse
-
#initialize(endpoints = nil, linger: Float::INFINITY, backend: nil) ⇒ SERVER
constructor
Creates a new SERVER socket.
-
#send_to(routing_id, message) ⇒ self
Sends a message to a specific peer by routing ID.
Constructor Details
#initialize(endpoints = nil, linger: Float::INFINITY, backend: nil) ⇒ SERVER
Creates a new SERVER socket.
39 40 41 42 43 |
# File 'lib/omq/client_server.rb', line 39 def initialize(endpoints = nil, linger: Float::INFINITY, backend: nil) init_engine(:SERVER, backend: backend) @options.linger = linger attach_endpoints(endpoints, default: :bind) end |
Instance Method Details
#send_to(routing_id, message) ⇒ self
Sends a message to a specific peer by routing ID.
52 53 54 55 56 |
# File 'lib/omq/client_server.rb', line 52 def send_to(routing_id, ) parts = [routing_id.b.freeze, .b.freeze] Reactor.run(timeout: @options.write_timeout) { @engine.enqueue_send(parts) } self end |