Class: CZTop::Socket::DISH

Inherits:
CZTop::Socket show all
Defined in:
lib/cztop/socket/types.rb

Overview

Group-based pub/sub (vs topic-based). This is the subscriber socket.

Constant Summary

Constants inherited from CZTop::Socket

TypeNames

Constants included from CZTop::SendReceiveMethods

CZTop::SendReceiveMethods::JIFFY

Instance Attribute Summary

Attributes inherited from CZTop::Socket

#last_tcp_port

Attributes included from HasFFIDelegate

#ffi_delegate

Instance Method Summary collapse

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

#<<, #now, #read_timeout, #receive, #wait_readable, #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, #raise_zmq_err, #to_ptr

Constructor Details

#initialize(endpoints = nil) ⇒ DISH

Returns a new instance of DISH.

Parameters:

  • endpoints (String) (defaults to: nil)

    endpoints to connect to



335
336
337
338
339
# File 'lib/cztop/socket/types.rb', line 335

def initialize(endpoints = nil)
  super

  attach_ffi_delegate(Zsock.new_dish(endpoints))
end

Instance Method Details

#join(group) ⇒ void

This method returns an undefined value.

Joins the given group.

Parameters:

  • group (String)

    group to join, up to 15 characters

Raises:

  • (ArgumentError)

    when group name is invalid or group has already been joined before

  • (SystemCallError)

    in case of failure



348
349
350
351
# File 'lib/cztop/socket/types.rb', line 348

def join(group)
  rc = ffi_delegate.join(group)
  raise_zmq_err(format('unable to join group %p', group)) if rc == -1
end

#leave(group) ⇒ void

This method returns an undefined value.

Leaves the given group.

Parameters:

  • group (String)

    group to leave

Raises:

  • (ArgumentError)

    when group wasn’t joined before

  • (SystemCallError)

    in case of another failure



359
360
361
362
# File 'lib/cztop/socket/types.rb', line 359

def leave(group)
  rc = ffi_delegate.leave(group)
  raise_zmq_err(format('unable to leave group %p', group)) if rc == -1
end