lib/apnserver/server.rb in bpoweski-apnserver-0.0.14 vs lib/apnserver/server.rb in bpoweski-apnserver-0.0.15
- old
+ new
@@ -1,18 +1,19 @@
module ApnServer
class Server
attr_accessor :client, :bind_address, :port
- def initialize(pem, bind_address = '0.0.0.0', port = 22195)
+ def initialize(pem, bind_address = '0.0.0.0', port = 22195, log = nil)
@queue = EM::Queue.new
@client = ApnServer::Client.new(pem)
@bind_address, @port = bind_address, port
end
def start!
EventMachine::run do
- $logger.info "Starting APN Server on #{bind_address}:#{port}"
+ $log = log || Logger.new(STDOUT)
+ $log.info "Starting APN Server on #{bind_address}:#{port}"
EM.start_server(bind_address, port, ApnServer::ServerConnection) do |s|
s.queue = @queue
end