Class: Orchestrator::Service::Manager
- Inherits:
-
Core::ModuleManager
- Object
- Core::ModuleManager
- Orchestrator::Service::Manager
- Defined in:
- lib/orchestrator/service/manager.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
Attributes inherited from Core::ModuleManager
#current_user, #instance, #logger, #settings, #stattrak, #status, #thread
Instance Method Summary collapse
-
#initialize(*args) ⇒ Manager
constructor
A new instance of Manager.
-
#notify_connected ⇒ Object
- NOTE
- Same as Device::Manager:——- TODO
-
Need to have a guess about when a device may be off line.
- #notify_received(data, resolve, command = nil) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Core::ModuleManager
#add_subscription, #define_setting, #get_scheduler, #get_system, #inspect, #reloaded, #setting, #subscribe, #trak, #unsubscribe
Constructor Details
#initialize(*args) ⇒ Manager
Returns a new instance of Manager.
4 5 6 7 8 9 10 |
# File 'lib/orchestrator/service/manager.rb', line 4 def initialize(*args) super(*args) # Do we want to start here? # Should be ok. @thread.next_tick method(:start) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
12 13 14 |
# File 'lib/orchestrator/service/manager.rb', line 12 def connection @connection end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
12 13 14 |
# File 'lib/orchestrator/service/manager.rb', line 12 def processor @processor end |
Instance Method Details
#notify_connected ⇒ Object
- NOTE
-
Same as Device::Manager:——-
- TODO
-
Need to have a guess about when a device may be off line
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/orchestrator/service/manager.rb', line 34 def notify_connected if @instance.respond_to? :connected, true begin @instance.__send__(:connected) rescue => e @logger.print_error(e, 'error in module connected callback') end end update_connected_status(true) end |
#notify_received(data, resolve, command = nil) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/orchestrator/service/manager.rb', line 46 def notify_received(data, resolve, command = nil) begin blk = command.nil? ? nil : command[:on_receive] if blk.respond_to? :call blk.call(data, resolve, command) elsif @instance.respond_to? :received, true @instance.__send__(:received, data, resolve, command) else @logger.warn('no received function provided') :abort end rescue => e @logger.print_error(e, 'error in received callback') end end |
#start ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/orchestrator/service/manager.rb', line 14 def start @processor = Orchestrator::Device::Processor.new(self) super # Calls on load (allows setting of tls certs) @connection = TransportHttp.new(self, @processor) @processor.transport = @connection end |
#stop ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/orchestrator/service/manager.rb', line 23 def stop super @processor.terminate @processor = nil @connection.terminate @connection = nil end |