Class: CZTop::Socket::SUB
- Inherits:
-
CZTop::Socket
- Object
- CZTop::Socket
- CZTop::Socket::SUB
- Defined in:
- lib/cztop/socket/types.rb
Overview
Subscribe socket for the ZeroMQ Publish-Subscribe Pattern.
Constant Summary collapse
- EVERYTHING =
Returns subscription prefix to subscribe to everything.
''
Constants inherited from CZTop::Socket
Constants included from CZTop::SendReceiveMethods
CZTop::SendReceiveMethods::FD_TIMEOUT, CZTop::SendReceiveMethods::JIFFY
Instance Attribute Summary
Attributes inherited from CZTop::Socket
Attributes included from HasFFIDelegate
Instance Method Summary collapse
-
#initialize(endpoints = nil, subscription = nil) ⇒ 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 inherited from CZTop::Socket
#CURVE_client!, #CURVE_server!, #bind, #close, #connect, #disconnect, #inspect, #last_endpoint, new_by_type, #unbind
Methods included from HasFFIDelegate::ClassMethods
#ffi_delegate, #from_ffi_delegate
Methods included from PolymorphicZsockMethods
#set_unbounded, #signal, #wait
Methods included from CZTop::SendReceiveMethods
#<<, #read_timeout, #receive, #wait_for_fd_signal, #wait_writable, #write_timeout
Methods included from ZsockOptions
#fd, #options, #readable?, #to_io, #writable?
Methods included from HasFFIDelegate
#attach_ffi_delegate, #from_ffi_delegate, raise_zmq_err, #to_ptr
Constructor Details
#initialize(endpoints = nil, subscription = nil) ⇒ SUB
Returns a new instance of SUB.
184 185 186 187 188 |
# File 'lib/cztop/socket/types.rb', line 184 def initialize(endpoints = nil, subscription = nil) super(endpoints) attach_ffi_delegate(Zsock.new_sub(endpoints, subscription)) end |
Instance Method Details
#subscribe(prefix = EVERYTHING) ⇒ void
This method returns an undefined value.
Subscribes to the given prefix string.
196 197 198 |
# File 'lib/cztop/socket/types.rb', line 196 def subscribe(prefix = EVERYTHING) ffi_delegate.set_subscribe(prefix) end |
#unsubscribe(prefix) ⇒ void
This method returns an undefined value.
Unsubscribes from the given prefix.
204 205 206 |
# File 'lib/cztop/socket/types.rb', line 204 def unsubscribe(prefix) ffi_delegate.set_unsubscribe(prefix) end |