Class: Racoon::Firehose

Inherits:
Object
  • Object
show all
Defined in:
lib/racoon/firehose.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reactor, address = ZM::Address.new('*', 11555, :tcp), &feedback_callback) ⇒ Firehose

Returns a new instance of Firehose.



15
16
17
18
19
20
21
# File 'lib/racoon/firehose.rb', line 15

def initialize(reactor, address = ZM::Address.new('*', 11555, :tcp), &feedback_callback)
  @connections = {}
  @reactor = reactor
  @address = address
  @feedback_callback = feedback_callback
  @error_callback = nil
end

Instance Attribute Details

#connectionsObject

Returns the value of attribute connections.



13
14
15
# File 'lib/racoon/firehose.rb', line 13

def connections
  @connections
end

#error_callbackObject

Returns the value of attribute error_callback.



13
14
15
# File 'lib/racoon/firehose.rb', line 13

def error_callback
  @error_callback
end

#feedback_callbackObject

Returns the value of attribute feedback_callback.



13
14
15
# File 'lib/racoon/firehose.rb', line 13

def feedback_callback
  @feedback_callback
end

Instance Method Details

#on_attach(socket) ⇒ Object



23
24
25
# File 'lib/racoon/firehose.rb', line 23

def on_attach(socket)
  socket.bind(@address)
end

#on_readable(socket, messages) ⇒ Object



27
28
29
30
31
32
# File 'lib/racoon/firehose.rb', line 27

def on_readable(socket, messages)
  messages.each do |message|
    packet = YAML::load(message.copy_out_string)
    apns(packet[:project], packet[:bytes])
  end
end