Class: Celluloid::ZMQ::SubSocket
- Includes:
- ReadableSocket
- Defined in:
- lib/celluloid/zmq/sockets.rb
Overview
SubSockets are the counterpart of PubSockets (PUB/SUB)
Instance Attribute Summary
Attributes inherited from Socket
Instance Method Summary collapse
-
#initialize ⇒ SubSocket
constructor
A new instance of SubSocket.
- #subscribe(topic) ⇒ Object
- #unsubscribe(topic) ⇒ Object
Methods included from ReadableSocket
Methods inherited from Socket
#bind, #close, #connect, #identity, #identity=
Constructor Details
#initialize ⇒ SubSocket
Returns a new instance of SubSocket.
167 168 169 |
# File 'lib/celluloid/zmq/sockets.rb', line 167 def initialize super :sub end |
Instance Method Details
#subscribe(topic) ⇒ Object
171 172 173 174 175 |
# File 'lib/celluloid/zmq/sockets.rb', line 171 def subscribe(topic) unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::SUBSCRIBE, topic) raise IOError, "couldn't set subscribe: #{::ZMQ::Util.error_string}" end end |
#unsubscribe(topic) ⇒ Object
177 178 179 180 181 |
# File 'lib/celluloid/zmq/sockets.rb', line 177 def unsubscribe(topic) unless ::ZMQ::Util.resultcode_ok? @socket.setsockopt(::ZMQ::UNSUBSCRIBE, topic) raise IOError, "couldn't set unsubscribe: #{::ZMQ::Util.error_string}" end end |