Class: NNQ::RESPONDENT0

Inherits:
Socket
  • Object
show all
Defined in:
lib/nnq/surveyor_respondent.rb

Overview

RESPONDENT (nng respondent0): reply side of the survey pattern. Receives surveys, processes them, and optionally sends replies. Strict alternation: #receive then #send_reply.

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

#receiveString?

Blocks until the next survey arrives.

Returns:

  • (String, nil)

    survey body, or nil if the socket was closed



54
55
56
# File 'lib/nnq/surveyor_respondent.rb', line 54

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

#send_reply(body) ⇒ Object

Routes body back to the surveyor that sent the most recent survey.



60
61
62
63
# File 'lib/nnq/surveyor_respondent.rb', line 60

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