Class: MyShuttlecraft
- Inherits:
-
Shuttlecraft
- Object
- Shuttlecraft
- MyShuttlecraft
- Defined in:
- lib/shuttlecraft/shuttlecraft_app.rb
Constant Summary
Constants inherited from Shuttlecraft
Shuttlecraft::PROVIDER_TEMPLATE, Shuttlecraft::REGISTRATION_TEMPLATE, Shuttlecraft::VERSION
Instance Attribute Summary collapse
-
#msg_log ⇒ Object
readonly
Returns the value of attribute msg_log.
Attributes inherited from Shuttlecraft
#mothership, #name, #protocol, #ring_server
Instance Method Summary collapse
- #broadcast(msg) ⇒ Object
-
#initialize(opts = {}) ⇒ MyShuttlecraft
constructor
A new instance of MyShuttlecraft.
- #message_reciept(from) ⇒ Object
- #say(msg, from) ⇒ Object
Methods inherited from Shuttlecraft
default_name, #find_all_motherships, #initiate_communication_with_mothership, #provider_template, #register, #registered?, #unregister
Methods included from Shuttlecraft::Comms
#each_client, #each_service_uri, #initialize_comms, #registered_services, #update, #update!, #update?
Constructor Details
#initialize(opts = {}) ⇒ MyShuttlecraft
Returns a new instance of MyShuttlecraft.
5 6 7 8 |
# File 'lib/shuttlecraft/shuttlecraft_app.rb', line 5 def initialize(opts={}) super(opts) @msg_log = [] end |
Instance Attribute Details
#msg_log ⇒ Object (readonly)
Returns the value of attribute msg_log.
3 4 5 |
# File 'lib/shuttlecraft/shuttlecraft_app.rb', line 3 def msg_log @msg_log end |
Instance Method Details
#broadcast(msg) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/shuttlecraft/shuttlecraft_app.rb', line 10 def broadcast(msg) for _, uri in registered_services begin remote = DRbObject.new_with_uri(uri) remote.say(msg, DRb.uri) rescue DRb::DRbConnError end end end |
#message_reciept(from) ⇒ Object
29 30 31 |
# File 'lib/shuttlecraft/shuttlecraft_app.rb', line 29 def (from) puts "reciept from #{from}" end |
#say(msg, from) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/shuttlecraft/shuttlecraft_app.rb', line 20 def say(msg, from) @msg_log << msg begin remote = DRbObject.new_with_uri(from) remote.(@name) rescue DRb::DRbConnError end end |