Class: Celluloid::ZMQ::Socket::Sub
- Inherits:
-
Celluloid::ZMQ::Socket
- Object
- Celluloid::ZMQ::Socket
- Celluloid::ZMQ::Socket::Sub
- Includes:
- Readable
- Defined in:
- lib/celluloid/zmq/socket/types.rb
Overview
SubSockets are the counterpart of PubSockets (PUB/SUB)
Instance Attribute Summary
Attributes inherited from Celluloid::ZMQ::Socket
Instance Method Summary collapse
-
#initialize ⇒ Sub
constructor
A new instance of Sub.
- #subscribe(topic) ⇒ Object
- #unsubscribe(topic) ⇒ Object
Methods included from Readable
#bind, #connect, #read, #read_multipart
Methods inherited from Celluloid::ZMQ::Socket
#bind, #close, #connect, #get, #identity, #identity=, #set
Constructor Details
#initialize ⇒ Sub
Returns a new instance of Sub.
86 87 88 |
# File 'lib/celluloid/zmq/socket/types.rb', line 86 def initialize super :sub end |
Instance Method Details
#subscribe(topic) ⇒ Object
90 91 92 93 94 |
# File 'lib/celluloid/zmq/socket/types.rb', line 90 def subscribe(topic) unless result_ok? @socket.setsockopt(::ZMQ::SUBSCRIBE, topic) fail IOError, "couldn't set subscribe: #{::ZMQ::Util.error_string}" end end |
#unsubscribe(topic) ⇒ Object
96 97 98 99 100 |
# File 'lib/celluloid/zmq/socket/types.rb', line 96 def unsubscribe(topic) unless result_ok? @socket.setsockopt(::ZMQ::UNSUBSCRIBE, topic) fail IOError, "couldn't set unsubscribe: #{::ZMQ::Util.error_string}" end end |