Sha256: 736ffb983c93d43911f52efacd6a4b515d27404f3896919cabe463c35163e02e

Contents?: true

Size: 735 Bytes

Versions: 1

Compression:

Stored size: 735 Bytes

Contents

module Aggro
  module ZeroMQTransport
    # Public: Client for making requests against a nanomsg server.
    class Client
      def initialize(endpoint)
        @endpoint = endpoint
      end

      def post(message)
        request_socket.send_string message.to_s

        response = ''
        request_socket.recv_string response

        response
      end

      def close_socket
        request_socket.close if @open
        @request_socket = nil
        @open = false
      end

      private

      def request_socket
        @request_socket ||= begin
          @open = true
          socket = ZeroMQTransport.context.socket(ZMQ::REQ)
          socket.connect @endpoint

          socket
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aggro-0.0.4 lib/aggro/zeromq_transport/client.rb