Class: DripDrop::ZMQSubHandler
- Inherits:
-
ZMQBaseHandler
- Object
- BaseHandler
- ZMQBaseHandler
- DripDrop::ZMQSubHandler
- Includes:
- ZMQReadableHandler
- Defined in:
- lib/dripdrop/handlers/zeromq.rb
Instance Attribute Summary collapse
-
#topic_filter ⇒ Object
Returns the value of attribute topic_filter.
Attributes included from ZMQReadableHandler
Attributes inherited from ZMQBaseHandler
Instance Method Summary collapse
-
#initialize(*args) ⇒ ZMQSubHandler
constructor
A new instance of ZMQSubHandler.
- #on_readable(socket, messages) ⇒ Object
- #post_setup ⇒ Object
Methods included from ZMQReadableHandler
Methods inherited from ZMQBaseHandler
Methods inherited from BaseHandler
#handle_error, #on_error, #print_exception
Constructor Details
#initialize(*args) ⇒ ZMQSubHandler
Returns a new instance of ZMQSubHandler.
133 134 135 136 |
# File 'lib/dripdrop/handlers/zeromq.rb', line 133 def initialize(*args) super(*args) self.topic_filter = @opts[:topic_filter] end |
Instance Attribute Details
#topic_filter ⇒ Object
Returns the value of attribute topic_filter.
131 132 133 |
# File 'lib/dripdrop/handlers/zeromq.rb', line 131 def topic_filter @topic_filter end |
Instance Method Details
#on_readable(socket, messages) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/dripdrop/handlers/zeromq.rb', line 138 def on_readable(socket, ) if @msg_format == :dripdrop unless .length == 2 return false end topic = .shift.copy_out_string if @topic_filter.nil? || topic.match(@topic_filter) body = .shift.copy_out_string @recv_cbak.call((body)) end else super(socket,) end end |
#post_setup ⇒ Object
153 154 155 156 |
# File 'lib/dripdrop/handlers/zeromq.rb', line 153 def post_setup super @connection.socket.setsockopt(ZMQ::SUBSCRIBE, '') end |