Class: LibSL::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

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_managerObject

Returns the value of attribute agent_manager.



14
15
16
# File 'lib/client.rb', line 14

def agent_manager
  @agent_manager
end

#event_managerObject

Returns the value of attribute event_manager.



14
15
16
# File 'lib/client.rb', line 14

def event_manager
  @event_manager
end

#network_managerObject

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

#loginObject



23
24
25
# File 'lib/client.rb', line 23

def ()
  @network_manager. @firstname, @lastname, @password, @start_location, @grid
end

#runObject



40
41
42
43
44
45
# File 'lib/client.rb', line 40

def run()
  
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

Returns:

  • (Boolean)


36
37
38
# File 'lib/client.rb', line 36

def setup?()
  @is_setup
end

#stopObject



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