lib/apple_push.rb in apple_push-0.1.1 vs lib/apple_push.rb in apple_push-0.1.2
- old
+ new
@@ -13,12 +13,13 @@
def self.configure(options={})
config = ApplePush::Configuration.new(options)
@@options.merge!(
- :host => config.host || '127.0.0.1',
- :port => config.port || '27000'
+ :host => config.host || '127.0.0.1',
+ :port => config.port || '27000',
+ :timeout => config.timeout || 5
)
if !config.sandbox? && !config.live?
raise ArgumentError, "At least one environment should be defined."
end
@@ -51,12 +52,15 @@
#
def self.setup_environment(env, config)
raise ArgumentError, "Path to certificate file required." if !config.cert?
raise ArgumentError, "Path to key file required." if !config.cert_key?
- pool_size = Integer(config.pool || 1)
-
- @@pools[env] = ConnectionPool.new(:size => pool_size, :timeout => 5) do
+ opts = {
+ :size => (Integer(config.pool || 1) rescue 1),
+ :timeout => configuration[:timeout]
+ }
+
+ @@pools[env] = ConnectionPool.new(opts) do
EM::APN::Client.connect(
:gateway => env == 'live' ? LIVE_URL : SANDBOX_URL,
:cert => File.expand_path(config.cert),
:key => File.expand_path(config.cert_key)
)