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
- @gateway_connection_pool = ConnectionPool.new(cp_args) do
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
- if @opts[:certificate_error_block].nil?
43
- Logger.warn "removing application #{@identifier} from the client due to bad certificate"
44
- APNS.client.remove_application @identifier
45
- else
46
- @opts[:certificate_error_block].call @identifier
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
- # FIXME
84
- t = @thread_count
85
- @applications[app_name].message device_id, message, opts
86
- @thread_count << t
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
@@ -1,3 +1,3 @@
1
1
  module LeadZeppelin
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lead_zeppelin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: