Class: NNQ::REP0

Inherits:
Socket show all
Defined in:
lib/nnq/req_rep.rb

Overview

REP (nng rep0): server side of request/reply. Strict alternation of #receive then #send_reply, per request.

Instance Attribute Summary

Attributes inherited from Socket

#options

Instance Method Summary collapse

Methods inherited from Socket

#all_peers_gone, bind, #bind, #close, #close_read, connect, #connect, #connection_count, #frozen_binary, #initialize, #last_endpoint, #monitor, #peer_connected, #raw?, #reconnect_enabled, #reconnect_enabled=

Constructor Details

This class inherits a constructor from NNQ::Socket

Instance Method Details

#receiveObject

Blocks until the next request arrives. Returns the request body.



40
41
42
# File 'lib/nnq/req_rep.rb', line 40

def receive
  Reactor.run { @engine.routing.receive }
end

#send_reply(body) ⇒ Object

Routes body back to the pipe the most recent #receive came from.



46
47
48
49
# File 'lib/nnq/req_rep.rb', line 46

def send_reply(body)
  body = frozen_binary(body)
  Reactor.run { @engine.routing.send_reply(body) }
end