class Staccato::Proxy::Listener

Constants

FRAME_SIZE

Public Class Methods

new(host, port, debug = false) click to toggle source
# File lib/staccato/proxy/listener.rb, line 7
def initialize(host, port, debug = false)
  @socket = UDPSocket.new.tap {|s| s.bind(host, port)}
  @debug = debug

  async.run
end

Public Instance Methods

debug(msg) click to toggle source
# File lib/staccato/proxy/listener.rb, line 35
def debug(msg)
  log(msg) if @debug
end
finalize() click to toggle source
# File lib/staccato/proxy/listener.rb, line 14
def finalize
  @socket.close if @socket
end
log(msg) click to toggle source
# File lib/staccato/proxy/listener.rb, line 31
def log(msg)
  Celluloid.logger.info(msg)
end
receive(data) click to toggle source
# File lib/staccato/proxy/listener.rb, line 22
def receive(data)
  debug data
  sender.async.submit(data[0])
end
run() click to toggle source
# File lib/staccato/proxy/listener.rb, line 18
def run
  loop {async.receive(@socket.recvfrom(FRAME_SIZE))}
end
sender() click to toggle source
# File lib/staccato/proxy/listener.rb, line 27
def sender
  Celluloid::Actor[:staccato_proxy_sender]
end