Class: LanGrove::Adaptor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/langrove/adaptor_base.rb

Direct Known Subclasses

Datagram

Instance Method Summary collapse

Constructor Details

#initialize(config, logger) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/langrove/adaptor_base.rb', line 9

def initialize( config, logger )

  @config = config
  @logger = logger

  @iface     = '127.0.0.1'
  @port      = 12701
  
  @iface   = @config[ :iface ] if @config.has_key? :iface
  @port    = @config[ :port ]  if @config.has_key? :port
  
  if @config.has_key? :connector then
    
    #
    # TODO: may need to override default connection handler
    #
    
  end
  
  #
  # initialize the client specified in config
  # 
  # daemons:
  #   name_of_daemon:
  #     adaptor:
  #       connection: TcpServer
  #       client:
  #         class: Client <---------
  #     handler:
  #       collection: CollectionOfClients 
  #
  # 
  
  @logger.info "TODO: loading client is not tested"
  
  client = nil
  
  begin 
    
    #
    # TODO: make this more informative on error
    #
  
    @client_config = @config[ :client ]
    client  = @client_config[ :class ]
    
  rescue
    
    error = "Missing config item(s) for adaptor: #{@config.inspect}" 

    @logger.error "EXIT: #{error}"

    raise LanGrove::DaemonConfigException.new( 

      "Missing config item for daemon: #{@daemon_name}" 

    )
    
  end

  @logger.info "Load definition: Client::#{client}"

  @client = LanGrove::ClassLoader.create( {

    :module => 'Client',
    :class  => client

  } )
  

end

Instance Method Details

#listen(handler, protocol) ⇒ Object



81
82
83
84
85
# File 'lib/langrove/adaptor_base.rb', line 81

def listen( handler, protocol )

  raise LanGrove::DaemonConfigException.new( "NotYetExtended: undefined listen()" )

end