Current section

57 Versions

Jump to

Compare versions

6 files changed
+12 additions
-18 deletions
  @@ -33,4 +33,4 @@
33 33 {<<"name">>,<<"chatterbox">>},
34 34 {<<"optional">>,true},
35 35 {<<"requirement">>,<<"~> 0.4.0">>}]]}.
36 - {<<"version">>,<<"0.12.1">>}.
36 + {<<"version">>,<<"0.13.0">>}.
  @@ -96,7 +96,8 @@ defmodule Pigeon.APNS do
96 96 cert: Config.cert(opts[:cert]),
97 97 certfile: Config.file_path(opts[:cert]),
98 98 key: Config.key(opts[:key]),
99 - keyfile: Config.file_path(opts[:key])
99 + keyfile: Config.file_path(opts[:key]),
100 + ping_period: opts[:ping_period] || 600_000
100 101 }
101 102 Pigeon.APNSWorker.start_link(config)
102 103 end
  @@ -14,7 +14,8 @@ defmodule Pigeon.APNS.Config do
14 14 certfile: file_path(config[:cert]),
15 15 key: key(config[:key]),
16 16 keyfile: file_path(config[:key]),
17 - use_2197: config[:use_2197] || false
17 + use_2197: config[:use_2197] || false,
18 + ping_period: config[:ping_period] || 600_000
18 19 }
19 20 end
  @@ -1,12 +1,10 @@
1 1 defmodule Pigeon.APNSWorker do
2 2 @moduledoc """
3 - Handles all APNS request and response parsing over an HTTP2 connection.
3 + Handles all APNS request and response parsing over an HTTP2 connection.
4 4 """
5 5 use GenServer
6 6 require Logger
7 7
8 - @ping_period 600_000 # 10 minutes
9 -
10 8 defp apns_production_api_uri, do: "api.push.apple.com"
11 9 defp apns_development_api_uri, do: "api.development.push.apple.com"
12 10
  @@ -32,7 +30,7 @@ defmodule Pigeon.APNSWorker do
32 30 mode = config[:mode]
33 31 case connect_socket(config, 0) do
34 32 {:ok, socket} ->
35 - Process.send_after(self(), :ping, @ping_period)
33 + Process.send_after(self(), :ping, config[:ping_period])
36 34 {:ok, %{
37 35 apns_socket: socket,
38 36 mode: mode,
  @@ -263,7 +261,7 @@ defmodule Pigeon.APNSWorker do
263 261
264 262 def handle_info(:ping, state) do
265 263 Pigeon.Http2.Client.default().send_ping(state.apns_socket)
266 - Process.send_after(self(), :ping, @ping_period)
264 + Process.send_after(self(), :ping, state.config.ping_period)
267 265
268 266 {:noreply, state}
269 267 end
  @@ -2,21 +2,15 @@ defmodule Pigeon.Http2.Client.Kadabra do
2 2 @behaviour Pigeon.Http2.Client
3 3
4 4 def connect(uri, scheme, opts) do
5 - if Code.ensure_loaded?(Kadabra) do
6 - Kadabra.open(uri, scheme, opts)
7 - end
5 + Kadabra.open(uri, scheme, opts)
8 6 end
9 7
10 8 def send_request(pid, headers, data) do
11 - if Code.ensure_loaded?(Kadabra) do
12 - Kadabra.request(pid, headers, data)
13 - end
9 + Kadabra.request(pid, headers, data)
14 10 end
15 11
16 12 def send_ping(pid) do
17 - if Code.ensure_loaded?(Kadabra) do
18 - Kadabra.ping(pid)
19 - end
13 + Kadabra.ping(pid)
20 14 end
21 15
22 16 def handle_end_stream({:end_stream, %{id: id,
Loading more files…