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
22
23
# 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
  @search_manager = SearchManager.new self
  @logger = Logger.new
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

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
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

#search_managerObject

Returns the value of attribute search_manager.



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

def search_manager
  @search_manager
end

Instance Method Details

#loginObject



30
31
32
# File 'lib/client.rb', line 30

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

#runObject



47
48
49
50
51
52
# File 'lib/client.rb', line 47

def run()
  
rescue LoginError => e
  puts "[ERROR] #{e.message}"
  EventMachine::stop_event_loop()
end

#setup(firstname, lastname, password, start = 'last', grid = :agni) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/client.rb', line 34

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)


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

def setup?()
  @is_setup
end

#stopObject



54
55
56
57
58
59
60
61
62
# File 'lib/client.rb', line 54

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