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, #get, #identity, #identity=, #set
Constructor Details
#initialize ⇒ SubSocket
Returns a new instance of SubSocket.
183 184 185 |
# File 'lib/celluloid/zmq/sockets.rb', line 183 def initialize super :sub end |
Instance Method Details
#subscribe(topic) ⇒ Object
187 188 189 190 191 |
# File 'lib/celluloid/zmq/sockets.rb', line 187 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
193 194 195 196 197 |
# File 'lib/celluloid/zmq/sockets.rb', line 193 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 |