Sha256: 4a3bdcb38f07f82f0cfecd1ec5a6ac0127bf838e098ca356bc156b8c766c77da

Contents?: true

Size: 701 Bytes

Versions: 6

Compression:

Stored size: 701 Bytes

Contents

module ZMQ

  class Device
    attr_reader :device

    def self.create(frontend, backend, capture=nil)
      dev = nil
      begin
        dev = new(frontend, backend, capture)
      rescue ArgumentError
        dev = nil
      end

      dev
    end

    def initialize(frontend, backend, capture=nil)
      [["frontend", frontend], ["backend", backend]].each do |name, socket|
        unless socket.is_a?(ZMQ::Socket)
          raise ArgumentError, "Expected a ZMQ::Socket, not a #{socket.class} as the #{name}"
        end
      end

      LibZMQ.zmq_proxy(frontend.socket, backend.socket, capture ? capture.socket : nil)
    end
  end
  
  # Alias for Device
  #
  class Proxy < Device; end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ffi-rzmq-2.0.7 lib/ffi-rzmq/device.rb
ffi-rzmq-2.0.6 lib/ffi-rzmq/device.rb
ffi-rzmq-2.0.5 lib/ffi-rzmq/device.rb
ffi-rzmq-2.0.4 lib/ffi-rzmq/device.rb
ffi-rzmq-2.0.1 lib/ffi-rzmq/device.rb
ffi-rzmq-2.0.0 lib/ffi-rzmq/device.rb