Class: Archipelago::Client::Base

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

Direct Known Subclasses

Exxon::Valdez, Pirate::Captain

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Initialize an instance using Archipelago::Disco::MC or :jockey if given, or a new Archipelago::Disco::Jockey if none, that looks for new services :initial_service_update_interval or INITIAL_SERVICE_UPDATE_INTERVAL, when it starts and never slower than every :maximum_service_update_interval or MAXIMUM_SERVICE_UPDATE_INTERVAL.



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

def initialize(options = {})
  setup(options)
end

Instance Attribute Details

#jockeyObject (readonly)

Returns the value of attribute jockey.



28
29
30
# File 'lib/archipelago/client.rb', line 28

def jockey
  @jockey
end

Instance Method Details

#setup(options = {}) ⇒ Object

Sets up this instance with the given options.



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/archipelago/client.rb', line 42

def setup(options = {})
  @jockey.stop! if defined?(@jockey) && @jockey != Archipelago::Disco::MC
  if defined?(Archipelago::Disco::MC)
    @jockey = options[:jockey] || Archipelago::Disco::MC
  else
    @jockey = options[:jockey] || Archipelago::Disco::Jockey.new
  end
  
  @initial_service_update_interval = options[:initial_service_update_interval] || INITIAL_SERVICE_UPDATE_INTERVAL
  @maximum_service_update_interval = options[:maximum_service_update_interval] || MAXIMUM_SERVICE_UPDATE_INTERVAL
end

#stop!Object

Stops the service update thread for this Pirate and also unpublishes and/or stops the Jockey.



58
59
60
61
62
63
# File 'lib/archipelago/client.rb', line 58

def stop!
  @service_update_thread.kill if @service_update_thread
  unless defined?(Archipelago::Disco::MC) && @jockey && @jockey == Archipelago::Disco::MC
    @jockey.stop!
  end
end

#update_services!Object

Override this to do whatever you want to when finding services.



68
69
70
# File 'lib/archipelago/client.rb', line 68

def update_services!
  # /moo
end