Class: Pione::Agent::Messenger
- Inherits:
-
TupleSpaceClient
- Object
- PioneObject
- BasicAgent
- TupleSpaceClient
- Pione::Agent::Messenger
- Defined in:
- lib/pione/agent/messenger.rb
Overview
Messenger is an agent for receiveing message logs.
Constant Summary
Constants included from Log::MessageLog
Log::MessageLog::MESSAGE_QUEUE
Instance Attribute Summary
Attributes inherited from BasicAgent
Instance Method Summary collapse
-
#initialize(tuple_space, receiver, session_id) ⇒ Messenger
constructor
A new instance of Messenger.
-
#transit_to_pass ⇒ Object
Transits to the state
pass
.
Methods inherited from TupleSpaceClient
#bye, #call_transition_method, #hello, #transit_to_init, #transit_to_terminate
Methods included from Log::MessageLog
#debug_message, #debug_message_begin, #debug_message_end, debug_mode, debug_mode=, debug_mode?, message, quiet_mode, quiet_mode=, quiet_mode?, #show, #user_message, #user_message_begin, #user_message_end
Methods included from TupleSpaceClientOperation
#base_location, #bye, #finalize, #hello, #notify_exception, #read, #take
Methods included from TupleSpace::TupleSpaceInterface
#process_log, #processing_error, #set_tuple_space, tuple_space_operation, #tuple_space_server, #with_process_log
Methods inherited from BasicAgent
agent_type, inherited, set_agent_type, #start, #start!, #states, #terminate, #terminated?, #transit, #wait_until, #wait_until_after, #wait_until_before, #wait_until_terminated
Methods included from StateTransitionSingletonMethod
#chain, #define_exception_handler, #define_transition, #exception_handler, #start, #transition_chain
Constructor Details
#initialize(tuple_space, receiver, session_id) ⇒ Messenger
Returns a new instance of Messenger.
11 12 13 14 15 16 17 |
# File 'lib/pione/agent/messenger.rb', line 11 def initialize(tuple_space, receiver, session_id) super(tuple_space) # message log receiver @receiver = receiver @session_id = session_id end |
Instance Method Details
#transit_to_pass ⇒ Object
Transits to the state pass
.
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pione/agent/messenger.rb', line 33 def transit_to_pass tuples = take_all(TupleSpace::MessageTuple.any) tuples.sort{|a,b| a. <=> b.}.each do |tuple| tuple.contents.tap do |contents| (contents.kind_of?(String) ? [contents] : contents).each do |msg| @receiver.receive(msg, tuple.level, tuple.head, tuple.color, @session_id) end end end end |