Sha256: 8d11aa030a6f1f9a3e380c37f2a770fcf37d02bcf2136a151889bc74ebe782ab
Contents?: true
Size: 1023 Bytes
Versions: 9
Compression:
Stored size: 1023 Bytes
Contents
require_relative 'socket' # Syntactic sugar for 0MQ, because Ruby shouldn't feel like C. module EZMQ # Request socket that sends messages and receives replies. class Client < EZMQ::Socket # Creates a new Client socket. # # @param [Hash] options optional parameters. # @see EZMQ::Socket EZMQ::Socket for optional parameters. # # @return [Client] a new instance of Client. # def initialize(**options) super :connect, ZMQ::REQ, options end # Sends a message and waits to receive a response. # # @param [String] message the message to send. # @param [Hash] options optional parameters. # @option options [lambda] encode how to encode the message. # @option options [lambda] decode how to decode the message. # # @return [void] the decoded response message. # def request(message = '', **options) send message, options if block_given? yield receive options else receive options end end end end
Version data entries
9 entries across 9 versions & 1 rubygems