apns_simple 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/apns_simple/client.rb +13 -20
- data/lib/apns_simple/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 885ffeb9c1c47bc2dbdce4e9544583333805c6eb
|
4
|
+
data.tar.gz: 224b07b0dc020a6f6728713018f0c771f2ec5710
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87420a1bcd041e9edb43b3ae76a89a5a328cb36f56f19326bdf0b1fa01e15229e5e4fe9261e34d2d3e795f4763c010b3162362d48ea73972087bd00eaad3eb8b
|
7
|
+
data.tar.gz: c96326ca6e2dac6a58a24bd583a2d6fab6b99922318382d32108350beadd6ffab934e5cfa72f4e5d6af305cb2216ca3e09fc818b2f1788ebebd8a99217c28786
|
data/lib/apns_simple/client.rb
CHANGED
@@ -46,33 +46,26 @@ module ApnsSimple
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def push(notification)
|
49
|
-
notification.error = true
|
50
49
|
sock = TCPSocket.new(host, port)
|
51
50
|
ssl = OpenSSL::SSL::SSLSocket.new(sock, ssl_context)
|
51
|
+
ssl.sync = true
|
52
52
|
ssl.connect
|
53
53
|
ssl.write(notification.payload)
|
54
|
-
ssl.flush
|
55
54
|
|
56
|
-
ready = IO.select([ssl], [], [], TIMEOUT)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
if command == COMMAND
|
68
|
-
notification.error_code = code
|
69
|
-
notification.error_message = "CODE: #{code}, DESCRIPTION: #{CODES[code]}"
|
70
|
-
else
|
71
|
-
notification.error_message = "Unknown command received from APNS server: #{command}"
|
55
|
+
if (ready = IO.select([ssl], [], [], TIMEOUT))
|
56
|
+
readable_ssl_socket = ready.first.first
|
57
|
+
if (error = readable_ssl_socket.read(ERROR_BYTES_COUNT))
|
58
|
+
command, code, _index = error.unpack('ccN')
|
59
|
+
notification.error = true
|
60
|
+
if command == COMMAND
|
61
|
+
notification.error_code = code
|
62
|
+
notification.error_message = "CODE: #{code}, DESCRIPTION: #{CODES[code]}"
|
63
|
+
else
|
64
|
+
notification.error_message = "Unknown command received from APNS server: #{command}"
|
65
|
+
end
|
72
66
|
end
|
73
|
-
else
|
74
|
-
notification.error = false
|
75
67
|
end
|
68
|
+
|
76
69
|
ensure
|
77
70
|
ssl.close if ssl
|
78
71
|
sock.close if sock
|
data/lib/apns_simple/version.rb
CHANGED