Sha256: eccf4583bdb3e617bf740c8d88f5675dbace96ddc71ab90b7be02d6693b7d4f3

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

module ZMQ
  
  # The proxy connects a frontend socket to a backend socket. Conceptually,
  # data flows from frontend to backend. Depending on the socket types,
  # replies may flow in the opposite direction. The direction is conceptual
  # only; the proxy is fully symmetric and there is no technical difference
  # between frontend and backend.
  class Proxy
    
    # Create a running proxy object.
    def self.proxy(frontend, backend, capture = nil)
      new(frontend, backend, capture).tap { |p| p.run }
    end
    
    # Accepts a frontend, backend, and optional capture socket.
    # See http://api.zeromq.org/4-0:zmq-proxy
    def initialize(frontend, backend, capture = nil)
      @frontend = frontend.nil? ? nil : frontend.to_ptr
      @backend  = backend.nil?  ? nil : backend.to_ptr
      @capture  = capture.nil?  ? nil : capture.to_ptr
    end
    
    # Block the current thread with the event loop of the proxy
    def run
      LibZMQ.zmq_proxy @frontend, @backend, @capture
    end
    
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
0mq-0.5.3 lib/0mq/proxy.rb
0mq-0.5.2 lib/0mq/proxy.rb
0mq-0.5.1 lib/0mq/proxy.rb
0mq-0.5.0 lib/0mq/proxy.rb
0mq-0.4.1 lib/0mq/proxy.rb
0mq-0.4.0 lib/0mq/proxy.rb
0mq-0.3.0 lib/0mq/proxy.rb