Class: EZMQ::Subscriber
Overview
Subscribe socket that listens for messages with an optional topic.
Instance Attribute Summary (collapse)
-
- (Object) action
Returns the value of attribute action.
Attributes inherited from Socket
#context, #decode, #encode, #socket
Instance Method Summary (collapse)
-
- (Publisher) initialize(**options)
constructor
Creates a new Subscriber socket.
-
- (Boolean) subscribe(topic)
Establishes a new message filter on the socket.
-
- (Boolean) unsubscribe(topic)
Removes a message filter (as set with subscribe) from the socket.
Methods inherited from Socket
#bind, #connect, #listen, #receive, #send
Constructor Details
- (Publisher) initialize(**options)
The default behaviour is to output and messages received to STDOUT.
Creates a new Subscriber socket.
232 233 234 235 |
# File 'lib/ezmq.rb', line 232 def initialize(**) super :connect, ZMQ::SUB, subscribe [:topic] if [:topic] end |
Instance Attribute Details
- (Object) action
Returns the value of attribute action
220 221 222 |
# File 'lib/ezmq.rb', line 220 def action @action end |
Instance Method Details
- (Boolean) subscribe(topic)
By default, a Subscriber filters all incoming messages. Without
Establishes a new message filter on the socket.
calling subscribe at least once, no messages will be accepted. If topic was provided, #initialize calls #subscribe automatically.
prefix will be accepted.
248 249 250 |
# File 'lib/ezmq.rb', line 248 def subscribe(topic) @socket.setsockopt(ZMQ::SUBSCRIBE, topic) == 0 end |
- (Boolean) unsubscribe(topic)
Removes a message filter (as set with subscribe) from the socket.
259 260 261 |
# File 'lib/ezmq.rb', line 259 def unsubscribe(topic) @socket.setsockopt(ZMQ::UNSUBSCRIBE, topic) == 0 end |