Sha256: 718bd39ade58671cda63a6b5404c9b9ff28b5054b828092fc0265b3c31ea126c

Contents?: true

Size: 721 Bytes

Versions: 7

Compression:

Stored size: 721 Bytes

Contents

name 'udp transport'
always_start true

default[:host], default[:port] = Kurchatov::Config[:udp_responder].to_s.split(':')

run_if do
  !!Kurchatov::Config[:udp_responder]
end

helpers do
  def process(data, src)
    begin
      hash = JSON.parse(data)
      hash = hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
      event(hash)
      src.reply "sended\n\n"
      Log.debug("Send event from udp responder: #{hash.inspect}")
    rescue => e
      src.reply "failed to send: #{data.inspect}\n"
      Log.error("Failed parse #{data.inspect}, #{e.class}: #{e}\n #{e.backtrace.join("\n")}")
    end
  end
end

run do
  Socket.udp_server_loop(plugin.host, plugin.port) do |data, src|
    process(data, src)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kurchatov-0.4.7 lib/kurchatov/responders/udp_server.rb
kurchatov-0.4.6 lib/kurchatov/responders/udp_server.rb
kurchatov-0.4.5 lib/kurchatov/responders/udp_server.rb
kurchatov-0.4.4 lib/kurchatov/responders/udp_server.rb
kurchatov-0.4.3 lib/kurchatov/responders/udp_server.rb
kurchatov-0.4.2 lib/kurchatov/responders/udp_server.rb
kurchatov-0.4.1 lib/kurchatov/responders/udp_server.rb