class GameOverseer::Client::ServiceManager

Constants

CHANNELS
SERVICES

Public Class Methods

instance() click to toggle source
# File lib/gameoverseer/client/service_manager.rb, line 16
def self.instance
  @instance
end
instance=(instance) click to toggle source
# File lib/gameoverseer/client/service_manager.rb, line 20
def self.instance=instance
  @instance = instance
end
new() click to toggle source
# File lib/gameoverseer/client/service_manager.rb, line 7
def initialize
  GameOverseer::Client::ServiceManager.instance = self
  SERVICES.each_with_index do |s, index|
    if s.class == Class
      SERVICES[index] = s.new
    end
  end
end

Public Instance Methods

handle_packet(data, channel) click to toggle source
# File lib/gameoverseer/client/service_manager.rb, line 37
def handle_packet(data, channel)
  service_channel = data["channel"]
  # service_method  = data["mode"]

  CHANNELS.each do |service|
    if service[:channel] == service_channel
      service[:instance].process_data(data, channel)
    end
  end
end
register_channel(instance, string) click to toggle source
# File lib/gameoverseer/client/service_manager.rb, line 24
def register_channel(instance, string)
  service = CHANNELS.detect do |_service|
    if _service[:channel] == string
      true
    end
  end

  raise "channel '#{string}' in use by '#{service[:instance]}'" if service

  CHANNELS.push({instance: instance, channel: string})
  return true
end