Sha256: a063124ca5a4c2fbf7b7c7d71baa061a0beb516f01e595178057402bb0a68d01

Contents?: true

Size: 729 Bytes

Versions: 14

Compression:

Stored size: 729 Bytes

Contents

module Kurchatov
  module Responders
    class Udp < Kurchatov::Plugin

      include Kurchatov::Mixin::Event
      include Kurchatov::Mixin::Queue

      def initialize(conn)
        @host, @port = conn.split(':')
        @name = "udp responder #{@host}:#{@port}"
      end


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

      def process(data,src)
        begin
          event << JSON.parse(data)
          src.reply "sended\n\n"
        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
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kurchatov-0.0.5.pre5 lib/kurchatov/responders/udp.rb
kurchatov-0.0.5.pre4 lib/kurchatov/responders/udp.rb
kurchatov-0.0.5.pre2 lib/kurchatov/responders/udp.rb
kurchatov-0.0.5.pre1 lib/kurchatov/responders/udp.rb
kurchatov-0.0.4 lib/kurchatov/responders/udp.rb
kurchatov-0.0.4d lib/kurchatov/responders/udp.rb
kurchatov-0.0.4c lib/kurchatov/responders/udp.rb
kurchatov-0.0.4b lib/kurchatov/responders/udp.rb
kurchatov-0.0.3 lib/kurchatov/responders/udp.rb
kurchatov-0.0.3b lib/kurchatov/responders/udp.rb
kurchatov-0.0.3a lib/kurchatov/responders/udp.rb
kurchatov-0.0.2 lib/kurchatov/responders/udp.rb
kurchatov-0.0.2b lib/kurchatov/responders/udp.rb
kurchatov-0.0.1 lib/kurchatov/responders/udp.rb