lead_zeppelin 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ module LeadZeppelin
|
|
29
29
|
timeout: (@opts[:connection_pool_timeout] || CONNECTION_POOL_TIMEOUT)}
|
30
30
|
|
31
31
|
begin
|
32
|
-
|
32
|
+
gateway_connection_pool = ConnectionPool.new(cp_args) do
|
33
33
|
Gateway.new @ssl_context, (@opts[:gateway_opts] || {}).merge(notification_error_block: @opts[:notification_error_block],
|
34
34
|
certificate_error_block: @opts[:certificate_error_block],
|
35
35
|
application_identifier: @identifier)
|
@@ -38,19 +38,26 @@ module LeadZeppelin
|
|
38
38
|
rescue OpenSSL::SSL::SSLError => e
|
39
39
|
if e.message =~ /alert certificate unknown/
|
40
40
|
Logger.warn "bad certificate for #{@identifier}, failed to connect"
|
41
|
+
end
|
42
|
+
|
43
|
+
if e.message =~ /alert certificate expired/
|
44
|
+
Logger.warn "expired certificate for #{@identifier}, failed to connect"
|
45
|
+
end
|
41
46
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end
|
47
|
+
if @opts[:certificate_error_block].nil?
|
48
|
+
Logger.warn "removing application #{@identifier} from the client due to bad/invalid/expired certificate"
|
49
|
+
APNS.client.remove_application @identifier
|
50
|
+
else
|
51
|
+
@opts[:certificate_error_block].call @identifier
|
48
52
|
end
|
53
|
+
else
|
54
|
+
@gateway_connection_pool = gateway_connection_pool
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
58
|
def message(device_id, message, opts={})
|
53
59
|
connect if @gateway_connection_pool.nil?
|
60
|
+
return nil if @gateway_connection_pool.nil?
|
54
61
|
|
55
62
|
@gateway_connection_pool.with_connection do |gateway|
|
56
63
|
gateway.write Notification.new(device_id, message, opts)
|
@@ -80,10 +80,14 @@ module LeadZeppelin
|
|
80
80
|
Logger.debug "message: \"#{app_name}\", \"#{device_id}\", \"#{message}\""
|
81
81
|
Logger.thread 'm'
|
82
82
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
83
|
+
if @applications[app_name]
|
84
|
+
# FIXME
|
85
|
+
t = @thread_count
|
86
|
+
@applications[app_name].message device_id, message, opts
|
87
|
+
@thread_count << t
|
88
|
+
else
|
89
|
+
Logger.error "not sending message for #{app_name.to_s} because it is invalid or has been removed"
|
90
|
+
end
|
87
91
|
end
|
88
92
|
end
|
89
93
|
end
|