Class: ZMQMachine::Socket::Pub
- Inherits:
-
Object
- Object
- ZMQMachine::Socket::Pub
- Includes:
- Base
- Defined in:
- lib/zm/sockets/pub.rb
Instance Attribute Summary
Attributes included from Base
#kind, #poll_options, #raw_socket
Instance Method Summary collapse
-
#initialize(context, handler) ⇒ Pub
constructor
A new instance of Pub.
-
#on_attach(handler) ⇒ Object
Attach a handler to the PUB socket.
Methods included from Base
#attach, #bind, #connect, create, #identity, #identity=, #inspect, #resume_read, #resume_write, #send_message, #send_message_string, #send_messages
Constructor Details
#initialize(context, handler) ⇒ Pub
Returns a new instance of Pub.
44 45 46 47 48 49 |
# File 'lib/zm/sockets/pub.rb', line 44 def initialize context, handler @poll_options = ZMQ::POLLOUT @kind = :pub super end |
Instance Method Details
#on_attach(handler) ⇒ Object
Attach a handler to the PUB socket.
A PUB socket may only send messages.
This socket expects its handler
to implement the #on_writable methods. The #on_writable method will be called whenever a message may be enqueued without blocking.
For error handling purposes, the handler must also implement #on_writable_error.
63 64 65 66 67 |
# File 'lib/zm/sockets/pub.rb', line 63 def on_attach handler raise ArgumentError, "Handler must implement an #on_writable method" unless handler.respond_to? :on_writable raise ArgumentError, "Handler must implement an #on_writable_error method" unless handler.respond_to? :on_writable_error super end |