Sha256: c8f9ab88e58eec304c457fe0bef94d0f921933f38275b6fa44fad81212b9c4f5
Contents?: true
Size: 912 Bytes
Versions: 8
Compression:
Stored size: 912 Bytes
Contents
module ApnServer class Server attr_accessor :client, :bind_address, :port def initialize(pem, bind_address = '0.0.0.0', port = 22195) @queue = EM::Queue.new @client = ApnServer::Client.new(pem) @bind_address, @port = bind_address, port end def start! EventMachine::run do puts "#{Time.now} Starting APN Server on #{bind_address}:#{port}" EM.start_server(bind_address, port, ApnServer::ServerConnection) do |s| s.queue = @queue end EventMachine::PeriodicTimer.new(1) do unless @queue.empty? size = @queue.size size.times do @queue.pop do |notification| @client.connect! unless @client.connected? @client.write(notification) end end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems