Sha256: f23500f569b84288b167881ebff5df71e45a784d375e29c0bfdab09017ebfb41

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

class FnordMetric::InboundDatagram < EventMachine::Connection

  class << self
    attr_accessor :opts
  end

  def self.start(opts)
    self.opts = opts
    EM.open_datagram_socket(*opts[:inbound_stream], self, opts)
  end

  def receive_data(event)
    events << event
    push_next_event
  end

  def push_next_event
    return true if events.empty?
    api.event(@events.pop)
    EM.next_tick(&method(:push_next_event))
  end

  def unbind
    api.disconnect
  end

  def api
    @api ||= FnordMetric::API.new(self.class.opts)
  end

  def events
    @events ||= []
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fnordmetric-0.7.3 lib/fnordmetric/inbound_datagram.rb