kw_apn 0.4.beta.4 → 0.4.beta.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/config.rb +9 -1
- data/lib/connection.rb +1 -1
- data/lib/feedback_reader.rb +2 -1
- data/lib/sender.rb +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.beta.
|
1
|
+
0.4.beta.6
|
data/lib/config.rb
CHANGED
@@ -34,11 +34,12 @@ module KwAPN
|
|
34
34
|
@options = begin
|
35
35
|
raw_config = File.read(root.join("config", "kw_apn.yml"))
|
36
36
|
parsed_config = ERB.new(raw_config).result
|
37
|
-
YAML.load(parsed_config)[env]
|
37
|
+
YAML.load(parsed_config)[env]
|
38
38
|
rescue => e
|
39
39
|
puts "Warning (KwAPN): Could not parse config file: #{e.message}"
|
40
40
|
{}
|
41
41
|
end
|
42
|
+
recursive_symbolize_keys!(@options)
|
42
43
|
@options[:root] ||= root
|
43
44
|
@options[:push_host] ||= default_push_host
|
44
45
|
@options[:feedback_host] ||= default_feedback_host
|
@@ -48,12 +49,19 @@ module KwAPN
|
|
48
49
|
# returns or loads the current options
|
49
50
|
def option(opt, app_id = nil)
|
50
51
|
@options || load_options
|
52
|
+
opt = opt.to_sym
|
53
|
+
app_id = app_id.to_sym
|
51
54
|
if app_id && @options[app_id] && @options[app_id][opt]
|
52
55
|
@options[app_id][opt]
|
53
56
|
else
|
54
57
|
@options[opt]
|
55
58
|
end
|
56
59
|
end
|
60
|
+
|
61
|
+
def recursive_symbolize_keys!(hash)
|
62
|
+
hash.symbolize_keys!
|
63
|
+
hash.values.select{|v| v.is_a? Hash}.each{|h| recursive_symbolize_keys!(h)}
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
59
67
|
# set some default options based on the envrionment
|
data/lib/connection.rb
CHANGED
@@ -9,7 +9,7 @@ module KwAPN
|
|
9
9
|
ctx = OpenSSL::SSL::SSLContext.new()
|
10
10
|
ctx.cert = OpenSSL::X509::Certificate.new(File.read(KwAPN::Config.option(:cert_file, app_id)))
|
11
11
|
ctx.key = OpenSSL::PKey::RSA.new(File.read(KwAPN::Config.option(:cert_file, app_id)))
|
12
|
-
|
12
|
+
puts '-------------------------------------------- ' + host.inspect
|
13
13
|
s = TCPSocket.new(host, port)
|
14
14
|
ssl = OpenSSL::SSL::SSLSocket.new(s, ctx)
|
15
15
|
ssl.connect # start SSL session
|
data/lib/feedback_reader.rb
CHANGED
@@ -5,12 +5,13 @@ module KwAPN
|
|
5
5
|
def initialize(app_id = nil)
|
6
6
|
@host = KwAPN::Config.option(:feedback_host, app_id)
|
7
7
|
@port = KwAPN::Config.option(:feedback_port, app_id)
|
8
|
+
@app_id = app_id
|
8
9
|
end
|
9
10
|
|
10
11
|
def read
|
11
12
|
records ||= []
|
12
13
|
begin
|
13
|
-
@ssl = connect(@host, @port)
|
14
|
+
@ssl = connect(@host, @port, @app_id)
|
14
15
|
while record = @ssl.read(38)
|
15
16
|
feedback = record.strip.unpack('NnH*')
|
16
17
|
records << feedback[2].scan(/.{0,8}/).join(' ').strip
|
data/lib/sender.rb
CHANGED
@@ -30,7 +30,7 @@ module KwAPN
|
|
30
30
|
return [:ok, @failed_index_array.collect{|a| notifications[a].token}]
|
31
31
|
rescue => e
|
32
32
|
failed
|
33
|
-
self.class.log("(#{app_id} - #{session_id}) Exception: #{e.message}")
|
33
|
+
self.class.log("(#{app_id} - #{session_id}) Exception: #{e.message}\n\t#{e.backtrace.join("\n\t")}")
|
34
34
|
return [:nok, "Exception: #{e.message}"]
|
35
35
|
end
|
36
36
|
end
|
@@ -44,7 +44,7 @@ private
|
|
44
44
|
|
45
45
|
def start_threads(notifications, index=0)
|
46
46
|
@last_error_index = nil
|
47
|
-
@ssl = connect(@host, @port)
|
47
|
+
@ssl = connect(@host, @port, @app_id)
|
48
48
|
if @ssl
|
49
49
|
@watch_thread = Thread.new do
|
50
50
|
perform_watch()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kw_apn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196351
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
9
|
- beta
|
10
|
-
-
|
11
|
-
version: 0.4.beta.
|
10
|
+
- 6
|
11
|
+
version: 0.4.beta.6
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Jonathan Cichon
|