Class: CZTop::Socket::SUB
- Inherits:
-
CZTop::Socket
- Object
- CZTop::Socket
- CZTop::Socket::SUB
- Includes:
- Readable
- Defined in:
- lib/cztop/socket/sub.rb
Overview
Subscribe socket for the ZeroMQ Publish-Subscribe Pattern.
Constant Summary collapse
- EVERYTHING =
Returns subscription prefix to subscribe to everything.
''
Constants included from FdWait
FdWait::FD_TIMEOUT, FdWait::JIFFY
Constants inherited from CZTop::Socket
Constants included from CZMQ::FFI
CZMQ::FFI::CZMQ_VERSION, CZMQ::FFI::ZFRAME_DONTWAIT, CZMQ::FFI::ZFRAME_MORE, CZMQ::FFI::ZMONITOR_FN, CZMQ::FFI::ZMQ_VERSION
Constants included from ZsockOptions
ZsockOptions::POLLIN, ZsockOptions::POLLOUT
Instance Attribute Summary
Attributes inherited from CZTop::Socket
Attributes included from HasFFIDelegate
Instance Method Summary collapse
-
#initialize(endpoints = nil, prefix: nil, curve: nil, linger: 0) ⇒ SUB
constructor
A new instance of SUB.
-
#subscribe(prefix = EVERYTHING) ⇒ void
Subscribes to the given prefix string.
-
#unsubscribe(prefix) ⇒ void
Unsubscribes from the given prefix.
Methods included from Readable
Methods included from FdWait
#wait_for_fd_signal, #wait_for_socket_state
Methods inherited from CZTop::Socket
bind, #bind, #close, #connect, connect, #disconnect, #inspect, #last_endpoint, #set_unbounded, #unbind
Methods included from HasFFIDelegate::ClassMethods
#ffi_delegate, #from_ffi_delegate
Methods included from ZsockOptions
#conflate=, #conflate?, #fd, #heartbeat_ivl, #heartbeat_ivl=, #heartbeat_timeout, #heartbeat_timeout=, #heartbeat_ttl, #heartbeat_ttl=, #identity, #identity=, #immediate=, #immediate?, #ipv6=, #ipv6?, #linger, #linger=, #max_msg_size, #max_msg_size=, #rcvhwm, #rcvhwm=, #readable?, #reconnect_ivl, #reconnect_ivl=, #reconnect_ivl_max, #reconnect_ivl_max=, #recv_timeout, #recv_timeout=, #router_mandatory=, #router_mandatory?, #send_timeout, #send_timeout=, #sndhwm, #sndhwm=, #tcp_keepalive, #tcp_keepalive=, #tcp_keepalive_cnt, #tcp_keepalive_cnt=, #tcp_keepalive_idle, #tcp_keepalive_idle=, #tcp_keepalive_intvl, #tcp_keepalive_intvl=, #to_io, #tos, #tos=, #writable?
Methods included from HasFFIDelegate
#attach_ffi_delegate, #from_ffi_delegate, raise_zmq_err, #to_ptr
Constructor Details
#initialize(endpoints = nil, prefix: nil, curve: nil, linger: 0) ⇒ SUB
Returns a new instance of SUB.
22 23 24 25 26 27 28 29 30 |
# File 'lib/cztop/socket/sub.rb', line 22 def initialize(endpoints = nil, prefix: nil, curve: nil, linger: 0) super(endpoints, curve: curve, linger: linger) attach_ffi_delegate(Zsock.new(Types::SUB)) self.linger = linger _apply_curve(curve) subscribe(prefix) unless prefix.nil? _attach(endpoints, default: :connect) end |
Instance Method Details
#subscribe(prefix = EVERYTHING) ⇒ void
This method returns an undefined value.
Subscribes to the given prefix string.
36 37 38 |
# File 'lib/cztop/socket/sub.rb', line 36 def subscribe(prefix = EVERYTHING) ffi_delegate.set_subscribe(prefix) end |
#unsubscribe(prefix) ⇒ void
This method returns an undefined value.
Unsubscribes from the given prefix.
45 46 47 |
# File 'lib/cztop/socket/sub.rb', line 45 def unsubscribe(prefix) ffi_delegate.set_unsubscribe(prefix) end |