Class: LibSL::Client
- Inherits:
-
Object
- Object
- LibSL::Client
- Defined in:
- lib/client.rb
Instance Attribute Summary collapse
-
#agent_manager ⇒ Object
Returns the value of attribute agent_manager.
-
#event_manager ⇒ Object
Returns the value of attribute event_manager.
-
#network_manager ⇒ Object
Returns the value of attribute network_manager.
Instance Method Summary collapse
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #login ⇒ Object
- #run ⇒ Object
- #setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object
- #setup? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
16 17 18 19 20 21 |
# File 'lib/client.rb', line 16 def initialize() @is_setup = false #@event_manager = EventManager.new self @network_manager = NetworkManager.new self @agent_manager = AgentManager.new self end |
Instance Attribute Details
#agent_manager ⇒ Object
Returns the value of attribute agent_manager.
14 15 16 |
# File 'lib/client.rb', line 14 def agent_manager @agent_manager end |
#event_manager ⇒ Object
Returns the value of attribute event_manager.
14 15 16 |
# File 'lib/client.rb', line 14 def event_manager @event_manager end |
#network_manager ⇒ Object
Returns the value of attribute network_manager.
14 15 16 |
# File 'lib/client.rb', line 14 def network_manager @network_manager end |
Instance Method Details
#login ⇒ Object
23 24 25 |
# File 'lib/client.rb', line 23 def login() @network_manager.login @firstname, @lastname, @password, @start_location, @grid end |
#run ⇒ Object
40 41 42 43 44 45 |
# File 'lib/client.rb', line 40 def run() login rescue LoginError => e puts "[ERROR] #{e.message}" EventMachine::stop_event_loop() end |
#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/client.rb', line 27 def setup(firstname, lastname, password, start='last', grid=:agni) @firstname = firstname @lastname = lastname @password = password @start_location = start @grid = grid @is_setup = true end |
#setup? ⇒ Boolean
36 37 38 |
# File 'lib/client.rb', line 36 def setup?() @is_setup end |
#stop ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/client.rb', line 47 def stop() EventManager::fire_event(:stopping) @network_manager.logout # Wait for all sims to disconnect EventMachine::add_timer(5) { EventManager::fire_event(:stopped) EventMachine::stop_event_loop() } end |