Class: RSMP::AckCollector

Inherits:
Collector show all
Defined in:
lib/rsmp/collect/ack_collector.rb

Overview

Class for waiting for a message acknowledgement

Instance Attribute Summary

Attributes inherited from Collector

#condition, #error, #m_id, #messages, #status, #task

Attributes included from Logging

#archive, #logger

Instance Method Summary collapse

Methods inherited from Collector

#cancel, #collect, #collect!, #complete, #describe, #do_stop, #done?, #incomplete, #inspect, #keep, #make_title, #ok!, #perform_match, #receive, #receive_disconnect, #receive_error, #receive_schema_error, #reject_not_ack, #reset, #start, #use_task, #wait, #wait!

Methods included from Logging

#author, #initialize_logging, #log

Methods included from Collector::Reporting

#describe_matcher, #describe_num_and_type, #describe_progress, #describe_types, #identifier

Methods included from Collector::Status

#cancelled?, #collecting?, #ingoing?, #ok?, #outgoing?, #ready?, #timeout?

Methods included from Receiver

#accept_message?, #handle_message, #initialize_receiver, #receive, #receive_error, #reject_message?, #start_receiving, #stop_receiving

Methods included from Inspect

#inspect, #inspector

Constructor Details

#initialize(proxy, options = {}) ⇒ AckCollector

Returns a new instance of AckCollector.

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
12
# File 'lib/rsmp/collect/ack_collector.rb', line 4

def initialize(proxy, options = {})
  raise ArgumentError, 'm_id must be provided' unless options[:m_id]

  super(proxy, options.merge(
    filter: RSMP::Filter.new(ingoing: true, outgoing: false, type: 'MessageAck'),
    num: 1,
    title: 'message acknowledgement'
  ))
end

Instance Method Details

#acceptable?(message) ⇒ Boolean

Check if we the MessageAck related to initiating request, identified by @m_id.

Returns:

  • (Boolean)


15
16
17
# File 'lib/rsmp/collect/ack_collector.rb', line 15

def acceptable?(message)
  super && message.attribute('oMId') == @m_id
end