Class: Celluloid::ZMQ::SubSocket

Inherits:
Socket
  • Object
show all
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

#linger

Instance Method Summary collapse

Methods included from ReadableSocket

#bind, #connect, #read

Methods inherited from Socket

#bind, #close, #connect, #identity, #identity=

Constructor Details

#initializeSubSocket

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