Class: Citrus::ConsoleModules::MasterWatcher

Inherits:
ConsoleModule show all
Defined in:
lib/citrus/modules/master_watcher.rb

Overview

MaterWatcher

Instance Attribute Summary

Attributes inherited from ConsoleModule

#delay, #interval, #type

Instance Method Summary collapse

Methods inherited from ConsoleModule

inherited

Constructor Details

#initialize(args = {}, console_service) ⇒ MasterWatcher

Initialize the module

Parameters:

  • args (Hash) (defaults to: {})
  • console_service (Object)


24
25
26
27
28
29
30
31
32
# File 'lib/citrus/modules/master_watcher.rb', line 24

def initialize args={}, console_service
  @app = args[:app]
  @service = console_service
  @server_id = @app.server_id
  @watchdog = Master::WatchDog.new @app, @service
  @service.on('register') { |*args| on_server_add *args }
  @service.on('disconnect') { |*args| on_server_leave *args }
  @service.on('reconnect') { |*args| on_server_reconnect *args }
end

Instance Method Details

#master_handler(agent, msg, &block) ⇒ Object

Master handler

Parameters:

  • agent (Object)
  • msg (Hash)


43
44
45
46
47
48
49
50
# File 'lib/citrus/modules/master_watcher.rb', line 43

def master_handler agent, msg, &block
  return if !msg
  case msg[:action]
  when 'subscribe'
    handle_subscribe agent, msg, &block
  else
  end
end

#start(&block) ⇒ Object

Start the module



35
36
37
# File 'lib/citrus/modules/master_watcher.rb', line 35

def start &block
  block_given? and yield
end