Class: EZMQ::Client

Inherits:
Socket show all
Defined in:
lib/ezmq.rb

Overview

Request socket that sends messages and receives replies.

Instance Attribute Summary

Attributes inherited from Socket

#context, #decode, #encode, #socket

Instance Method Summary (collapse)

Methods inherited from Socket

#bind, #connect, #receive, #send

Constructor Details

- (Client) initialize(**options)

Creates a new Client socket.

Parameters:

  • options (Hash)

    optional parameters.

See Also:



119
120
121
# File 'lib/ezmq.rb', line 119

def initialize(**options)
  super :connect, ZMQ::REQ, options
end

Instance Method Details

- (void) request(message = '', **options)

This method returns an undefined value.

Sends a message and waits to receive a response.

Parameters:

  • message (String) (defaults to: '')

    the message to send.

  • options (Hash)

    optional parameters.

Options Hash (**options):

  • encode (lambda)

    how to encode the message.

  • decode (lambda)

    how to decode the message.



132
133
134
135
136
137
138
139
# File 'lib/ezmq.rb', line 132

def request(message = '', **options)
  send message, options
  if block_given?
    yield receive options
  else
    receive options
  end
end