Class: LanGrove::Adaptor::Datagram

Inherits:
Base
  • Object
show all
Defined in:
lib/langrove/adaptor/datagram.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from LanGrove::Adaptor::Base

Instance Method Details

#listen(handler, protocol) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/langrove/adaptor/datagram.rb', line 7

def listen( handler, protocol )

  @logger.info "starting listen at UDP #{@iface}:#{@port}"
  
  EventMachine::open_datagram_socket( @iface, @port, 
  
    @client ) do |client|
      
      @logger.info "client assign handler: #{handler}"
      client.handler  = handler
      
      @logger.info "client instanciate protocol: #{protocol}"
      client.protocol = protocol.new( nil, @logger )
      
      @logger.info "client assign config: #{@client_config}"
      client.config = @client_config.clone
      
  end
end