Class: FFWD::Tunnel::UDP

Inherits:
Object
  • Object
show all
Includes:
Lifecycle, Reporter
Defined in:
lib/ffwd/tunnel/udp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reporter

included, #increment, map_meta, #report!, #reporter_data

Methods included from Lifecycle

#depend_on, #start, #started?, #starting, #starting_hooks, #stop, #stopped?, #stopping, #stopping_hooks

Constructor Details

#initialize(port, core, plugin, log, connection, args) ⇒ UDP



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
# File 'lib/ffwd/tunnel/udp.rb', line 29

def initialize port, core, plugin, log, connection, args
  @port = port
  @core = core
  @plugin = plugin
  @log = log
  @connection = connection
  @args = args

  @instance = nil

  starting do
    @instance = @connection.new(nil, self, @core, *@args)

    @plugin.udp @port do |handle, data|
      @instance.datasink = handle
      @instance.receive_data data
      @instance.datasink = nil
    end

    @log.info "Tunneling udp/#{@port}"
  end

  stopping do
    if @instance
      @instance.unbind
      @instance = nil
    end

    @log.info "Stopped tunnelling udp/#{@port}"
  end
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



27
28
29
# File 'lib/ffwd/tunnel/udp.rb', line 27

def log
  @log
end