Class: Zeromq::Proxy
- Inherits:
-
Object
- Object
- Zeromq::Proxy
- Defined in:
- lib/zeromq/proxy.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(frontend, backend) ⇒ Proxy
constructor
A new instance of Proxy.
Constructor Details
#initialize(frontend, backend) ⇒ Proxy
Returns a new instance of Proxy.
5 6 7 8 |
# File 'lib/zeromq/proxy.rb', line 5 def initialize(frontend, backend) @frontend = frontend @backend = backend end |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/zeromq/proxy.rb', line 10 def execute context = ZMQ::Context.new frontend = context.socket(ZMQ::PULL) bound = frontend.bind(@frontend) raise 'Error starting frontend!' unless bound == 0 backend = context.socket(ZMQ::PUSH) bound = backend.bind(@backend) raise 'Error starting backend!' unless bound == 0 ZMQ::Device.new(ZMQ::QUEUE,frontend,backend) end |