Class: LanGrove::Handler::Base
- Inherits:
-
Object
- Object
- LanGrove::Handler::Base
- Defined in:
- lib/langrove/handler_base.rb
Instance Attribute Summary collapse
-
#clients ⇒ Object
writeonly
One handler exists in the daemon with the primary purpose of housing through an addressable Hash the set of connected clients,.
-
#protocol ⇒ Object
readonly
The protocol defininition per the config is loaded by this Handler, but not instanciated.
Instance Method Summary collapse
- #daemon_start ⇒ Object
- #daemon_stop ⇒ Object
-
#initialize(config_hash, daemon_name, logger) ⇒ Base
constructor
A new instance of Base.
- #periodic ⇒ Object
Constructor Details
#initialize(config_hash, daemon_name, logger) ⇒ Base
Returns a new instance of Base.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/langrove/handler_base.rb', line 69 def initialize( config_hash, daemon_name, logger ) @config = config_hash @daemon_name = daemon_name @logger = logger @my_config = @config[ :daemons ][ @daemon_name ][ :handler ] protocol = 'Base' if @my_config.has_key? :protocol then protocol = @my_config[ :protocol ] end # # SIGNIFICANT DECISION # # - (currently) - There is one >>Instance<< of the protocol # # - It is an object ( has .new ) # # - All attached socket traffic is directed through it for de/encode # - # - ?.. ie. multiple TcpClients all routing through the same object..? # - # - THIS MAY NEED TO CHANGE (thinks & thinks & thinks) # # - (Thinks) - It may move to the Client::Base so that each attached # client is paired with its own instance of the protocol. # # - For now it wil be instanciated here and binded to each client at # connect - to be shared for the decoding. That should be fine for # as long as the protocol itself stores no state and is simply a # code path (Still, thinks & ... # # # initialize the protocol specified in config # # daemons: # # viking-invasion-early-warning-net_CoreHub_co_uk-D4RK1: # # adaptor: # connection: TriFocalOcularRotisserie # lightsource: # type: Fire # fuel: Peat # # handler: # collection: ScottishCoastalVillages # protocol: MedievalLanternMorse <---------- # # Note: This is the application layer protocol # and is therefore entirely agnostic of # transport and disassociated from the # adapter in use. # @logger.info "Load definition: Protocol::#{protocol}" @protocol = LanGrove::ClassLoader.create( { :module => 'Protocol', :class => protocol } ) end |
Instance Attribute Details
#clients=(value) ⇒ Object (writeonly)
One handler exists in the daemon with the primary purpose of housing through an addressable Hash the set of connected clients,
In this:
but, NOT YET
15 16 17 |
# File 'lib/langrove/handler_base.rb', line 15 def clients=(value) @clients = value end |
#protocol ⇒ Object (readonly)
The protocol defininition per the config is loaded by this Handler, but not instanciated.
This definition is then exposed,
By this:
25 26 27 |
# File 'lib/langrove/handler_base.rb', line 25 def protocol @protocol end |
Instance Method Details
#daemon_start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/langrove/handler_base.rb', line 27 def daemon_start # # OVERRIDE # # To prepare the Handler in any necessary # ways before the thread is handed over to # the socket listener, (or thing), # # The daemon has just started. # end |
#daemon_stop ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/langrove/handler_base.rb', line 41 def daemon_stop # # OVERRIDE # # To perfom any necessties before process # termination, # # The daemon has received a signal to stop. # end |
#periodic ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/langrove/handler_base.rb', line 54 def periodic # # TODO: There shall not only be one # # Changes are pending. # # OVERRIDE # # To perform activities at the interval # defined in the config. # end |