lead_zeppelin 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,8 +61,12 @@ module LeadZeppelin
61
61
  gateway = @gateway_pool.pop
62
62
  end
63
63
 
64
+ return false if gateway.nil?
65
+
64
66
  gateway.write Notification.new(device_id, message, opts)
65
67
  @gateway_pool.push gateway
68
+
69
+ true
66
70
  end
67
71
  end
68
72
  end
@@ -70,12 +70,12 @@ module LeadZeppelin
70
70
  def remove_application(name)
71
71
  Logger.info "removing application \"#{name}\""
72
72
  Logger.thread 'r'
73
-
73
+
74
74
  @semaphore.synchronize do
75
75
  deleted = @applications.delete name
76
- end
77
76
 
78
- Logger.warn "removing application \"#{name}\" failed! Name may be invalid." if deleted.nil?
77
+ Logger.warn "removing application \"#{name}\" failed! Name may be invalid." if deleted.nil?
78
+ end
79
79
  end
80
80
 
81
81
  def message(app_name, device_id, message, opts={})
@@ -1,9 +1,11 @@
1
1
  module LeadZeppelin
2
2
  module APNS
3
3
  class Gateway
4
- HOST = 'gateway.push.apple.com'
5
- PORT = 2195
6
- DEFAULT_TIMEOUT = 10
4
+ HOST = 'gateway.push.apple.com'
5
+ SANDBOX_HOST = 'gateway.sandbox.push.apple.com'
6
+
7
+ PORT = 2195
8
+ DEFAULT_TIMEOUT = 10
7
9
  DEFAULT_SELECT_WAIT = 0.3
8
10
 
9
11
  def initialize(ssl_context, opts={})
@@ -18,9 +20,11 @@ module LeadZeppelin
18
20
  Logger.thread 's'
19
21
  begin
20
22
  timeout(@opts[:timeout] || DEFAULT_TIMEOUT) do
21
- socket = TCPSocket.new((@opts[:host] || HOST), (@opts[:port] || PORT))
23
+ socket = TCPSocket.new (@opts[:host] || HOST), (@opts[:port] || PORT)
24
+ socket.setsockopt Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true
25
+
22
26
  ssl_socket = OpenSSL::SSL::SSLSocket.new socket, @ssl_context
23
-
27
+
24
28
  ssl_socket.sync_close = true # when ssl_socket is closed, make sure the regular socket closes too.
25
29
 
26
30
  ssl_socket.connect
@@ -72,7 +76,7 @@ module LeadZeppelin
72
76
  # FIXME put in a certificate error pre-check and perhaps an error block for handling this.
73
77
  # A better solution is the remove the application altogether from the client..
74
78
  # Sometimes this just means that the socket has disconnected. Apparently Apple does that too.
75
- #
79
+ #
76
80
  Logger.info "socket has closed for #{@opts[:application_identifier]}, reconnecting"
77
81
  reconnect
78
82
  rescue IO::WaitReadable
@@ -108,7 +112,7 @@ module LeadZeppelin
108
112
  reconnect
109
113
  retry
110
114
  end
111
-
115
+
112
116
  true
113
117
  end
114
118
 
@@ -1,3 +1,3 @@
1
1
  module LeadZeppelin
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
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.8
4
+ version: 0.1.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: