Module: GameOverseer::Services

Defined in:
lib/gameoverseer/services/services.rb

Constant Summary collapse

LIST =
[]
ACTIVE =
[]

Class Method Summary collapse

Class Method Details

.client_connected(client_id, ip_address) ⇒ Object

Tells all services that have ‘client_connected’ defined that ‘client_id’ has connected

Parameters:

  • client_id (Integer)

    ID of client

  • ip_address (String)

    ip address of client



24
25
26
27
28
# File 'lib/gameoverseer/services/services.rb', line 24

def self.client_connected(client_id, ip_address)
  ACTIVE.each do |service|
    service.client_connected(client_id, ip_address) if defined?(service.client_connected)
  end
end

.client_disconnected(client_id) ⇒ Object

Tells all services that have ‘client_disconnected’ defined that ‘client_id’ is now disconnected

Parameters:

  • client_id (Integer)

    ID of client



32
33
34
35
36
# File 'lib/gameoverseer/services/services.rb', line 32

def self.client_disconnected(client_id)
  ACTIVE.each do |service|
    service.client_disconnected(client_id) if defined?(service.client_disconnected)
  end
end

.enableObject

instantiates the Services in ‘LIST’ and adds them to the ‘ACTIVE’ list



13
14
15
16
17
18
19
# File 'lib/gameoverseer/services/services.rb', line 13

def self.enable
  LIST.each do |service|
    _service = service.new
    GameOverseer::Console.log "Services> #{_service.class} #{_service.version}"
    ACTIVE << _service
  end
end

.register(klass) ⇒ Object

Adds klass to list

Parameters:

  • klass (Service)

    Service class to add to services list



8
9
10
# File 'lib/gameoverseer/services/services.rb', line 8

def self.register(klass)
  LIST << klass
end