1 # The LWES::Emitter is used for emitting LWES events to a multicast
2 # network or a single host. It can emit LWES::Event objects, LWES::Struct
3 # objects, and even plain Ruby hashes.
5 # It is non-blocking and does not guarantee delivery.
8 # emitter = LWES::Emitter.new(:address => '224.1.1.11',
10 # :heartbeat => 30, # nil to disable
11 # :ttl => 1) # nil for default TTL(3)
19 # Since we can't reliably map certain Ruby types to LWES types, you'll
20 # have to specify them explicitly for IP addresses and all Integer
24 # :time_sec => [ :int32, Time.now.to_i ],
25 # :time_usec => [ :int32, Time.now.tv_usec ],
26 # :remote_addr => [ :ip_addr, "192.168.0.1" ],
29 # # Strings and Boolean values are easily mapped, however:
30 # event[:field1] = "String value"
31 # event[:boolean1] = true
32 # event[:boolean2] = false
34 # # finally, we just emit the hash with any given name
35 # emitter.emit "Event3", event
38 # creates a new Emitter object which may be used for the lifetime
41 # LWES::Emitter.new(:address => '224.1.1.11',
42 # :iface => '0.0.0.0',
44 # :heartbeat => false, # Integer for frequency
45 # :ttl => 60, # nil for no ttl)
47 def initialize(options = {}, &block)
48 options[:iface] ||= '0.0.0.0'