apnd 0.1.7 → 0.1.8
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.
- data/README.markdown +6 -2
- data/lib/apnd/daemon/protocol.rb +13 -9
- data/lib/apnd/version.rb +1 -1
- data/test/apnd_test.rb +2 -0
- metadata +4 -4
data/README.markdown
CHANGED
@@ -100,9 +100,13 @@ push notifications to APND.
|
|
100
100
|
|
101
101
|
# Send multiple notifications at once to avoid overhead in
|
102
102
|
# opening/closing the upstream socket connection each time
|
103
|
+
#
|
104
|
+
# *IMPORTANT!* Use sock.puts as it appends a new line. If you don't,
|
105
|
+
# you'll only receive the first notification.
|
106
|
+
|
103
107
|
APND::Notification.open_upstream_socket do |sock|
|
104
|
-
sock.
|
105
|
-
sock.
|
108
|
+
sock.puts(notification1.to_bytes)
|
109
|
+
sock.puts(notification2.to_bytes)
|
106
110
|
end
|
107
111
|
|
108
112
|
|
data/lib/apnd/daemon/protocol.rb
CHANGED
@@ -17,16 +17,11 @@ module APND
|
|
17
17
|
#
|
18
18
|
# Called when a client connection is closed
|
19
19
|
#
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
20
|
+
# Checks @buffer for any pending notifications to be
|
21
|
+
# queued
|
24
22
|
#
|
25
|
-
|
26
|
-
|
27
|
-
def receive_data(data)
|
28
|
-
(@buffer ||= "") << data
|
29
|
-
@buffer.each_line do |line|
|
23
|
+
def unbind
|
24
|
+
@buffer.chomp.split("\n").each do |line|
|
30
25
|
if notification = APND::Notification.valid?(line)
|
31
26
|
APND.ohai "#{@address.last}:#{@address.first} added new Notification to queue"
|
32
27
|
queue.push(notification)
|
@@ -34,6 +29,15 @@ module APND
|
|
34
29
|
APND.ohai "#{@address.last}:#{@address.first} submitted invalid Notification"
|
35
30
|
end
|
36
31
|
end
|
32
|
+
APND.ohai "#{@address.last}:#{@address.first} closed connection"
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Add incoming notification(s) to @buffer
|
37
|
+
#
|
38
|
+
def receive_data(data)
|
39
|
+
APND.ohai "#{@address.last}:#{@address.first} buffering data"
|
40
|
+
(@buffer ||= "") << data
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
data/lib/apnd/version.rb
CHANGED
data/test/apnd_test.rb
CHANGED
@@ -61,11 +61,13 @@ class APNDTest < Test::Unit::TestCase
|
|
61
61
|
|
62
62
|
should "add valid notification to queue" do
|
63
63
|
@daemon.receive_data(@@bytes)
|
64
|
+
@daemon.unbind
|
64
65
|
assert_equal 1, @daemon.queue.size
|
65
66
|
end
|
66
67
|
|
67
68
|
should "receive multiple Notifications in a single packet" do
|
68
69
|
@daemon.receive_data([@@bytes, @@bytes, @@bytes].join("\n"))
|
70
|
+
@daemon.unbind
|
69
71
|
assert_equal 3, @daemon.queue.size
|
70
72
|
end
|
71
73
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apnd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 8
|
10
|
+
version: 0.1.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Joshua Priddle
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-18 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|