push-gcm 0.0.1.pre → 0.0.1.pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/push/configuration_gcm.rb +11 -0
- data/lib/push/daemon/gcm_support/connection_gcm.rb +2 -2
- data/lib/push/feedback_gcm.rb +3 -0
- data/lib/push/message_gcm.rb +8 -6
- data/lib/push-gcm/version.rb +1 -1
- data/lib/push-gcm.rb +2 -0
- metadata +10 -9
@@ -2,13 +2,13 @@ module Push
|
|
2
2
|
module Daemon
|
3
3
|
module GcmSupport
|
4
4
|
class ConnectionGcm
|
5
|
-
attr_reader :response, :name
|
5
|
+
attr_reader :response, :name, :provider
|
6
6
|
PUSH_URL = "https://android.googleapis.com/gcm/send"
|
7
7
|
IDLE_PERIOD = 5.minutes
|
8
8
|
|
9
9
|
def initialize(provider, i)
|
10
10
|
@provider = provider
|
11
|
-
@name = "ConnectionGcm #{i}"
|
11
|
+
@name = "#{@provider.configuration[:name]}: ConnectionGcm #{i}"
|
12
12
|
end
|
13
13
|
|
14
14
|
def connect
|
data/lib/push/feedback_gcm.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Push
|
2
2
|
class FeedbackGcm < Push::Feedback
|
3
|
+
store :properties, accessors: [:update_to]
|
4
|
+
attr_accessible :app, :device, :follow_up, :failed_at, :update_to
|
3
5
|
|
6
|
+
validates :follow_up, :inclusion => { :in => %w(delete update), :message => "%{value} is not a valid follow-up" }
|
4
7
|
end
|
5
8
|
end
|
data/lib/push/message_gcm.rb
CHANGED
@@ -6,7 +6,7 @@ module Push
|
|
6
6
|
# Note that this includes both the size of the keys as well as the values.
|
7
7
|
|
8
8
|
store :properties, accessors: [:collapse_key, :delay_when_idle, :time_to_live, :payload]
|
9
|
-
attr_accessible :device, :collapse_key, :delay_when_idle, :time_to_live, :payload
|
9
|
+
attr_accessible :app, :device, :collapse_key, :delay_when_idle, :time_to_live, :payload
|
10
10
|
|
11
11
|
def to_message
|
12
12
|
hsh = Hash.new
|
@@ -38,7 +38,8 @@ module Push
|
|
38
38
|
|
39
39
|
if msg == "NotRegistered" or msg == "InvalidRegistration"
|
40
40
|
with_database_reconnect_and_retry(connection.name) do
|
41
|
-
Push::FeedbackGcm.create!(:
|
41
|
+
Push::FeedbackGcm.create!(:app => connection.provider.configuration[:name], :failed_at => Time.now,
|
42
|
+
:device => device, :follow_up => 'delete')
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
@@ -46,10 +47,11 @@ module Push
|
|
46
47
|
raise Push::DeliveryError.new(response.code, id, msg, "GCM")
|
47
48
|
elsif hsh["canonical_ids"] == 1
|
48
49
|
# success, but update device token
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
update_to = hsh["results"][0]["registration_id"]
|
51
|
+
with_database_reconnect_and_retry(connection.name) do
|
52
|
+
Push::FeedbackGcm.create!(:app => connection.provider.configuration[:name], :failed_at => Time.now,
|
53
|
+
:device => device, :follow_up => 'update', :update_to => update_to)
|
54
|
+
end
|
53
55
|
end
|
54
56
|
else
|
55
57
|
Push::Daemon.logger.error("[#{connection.name}] Error received.")
|
data/lib/push-gcm/version.rb
CHANGED
data/lib/push-gcm.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: push-gcm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.pre4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement: &
|
16
|
+
requirement: &70260456443140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,21 +21,21 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70260456443140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: push-core
|
27
|
-
requirement: &
|
27
|
+
requirement: &70260456442420 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.0.1.
|
32
|
+
version: 0.0.1.pre4
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70260456442420
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &70260456441380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70260456441380
|
47
47
|
description: GCM support for the modular push daemon.
|
48
48
|
email:
|
49
49
|
- tom@tnux.net
|
@@ -53,6 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- lib/push-gcm.rb
|
55
55
|
- lib/push-gcm/version.rb
|
56
|
+
- lib/push/configuration_gcm.rb
|
56
57
|
- lib/push/daemon/gcm.rb
|
57
58
|
- lib/push/daemon/gcm_support/connection_gcm.rb
|
58
59
|
- lib/push/feedback_gcm.rb
|