Class: Citrus::ConsoleModules::MasterWatcher
- Inherits:
-
ConsoleModule
- Object
- ConsoleModule
- Citrus::ConsoleModules::MasterWatcher
- Defined in:
- lib/citrus/modules/master_watcher.rb
Overview
MaterWatcher
Instance Attribute Summary
Attributes inherited from ConsoleModule
Instance Method Summary collapse
-
#initialize(args = {}, console_service) ⇒ MasterWatcher
constructor
Initialize the module.
-
#master_handler(agent, msg, &block) ⇒ Object
Master handler.
-
#start(&block) ⇒ Object
Start the module.
Methods inherited from ConsoleModule
Constructor Details
#initialize(args = {}, console_service) ⇒ MasterWatcher
Initialize the module
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
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 |