Copyright © Inaka <hello@inaka.net>
Behaviours: gen_statem.
This gen_statem handles the APNs Connection.
Copyright 2017 Erlang Solutions Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.connection() = #{name := name(), apple_host := host(), apple_port := inet:port_number(), certdata => binary(), certfile => path(), keydata => keydata(), keyfile => path(), timeout => integer(), type := type(), proxy_info => proxy_info()}
host() = string() | inet:ip_address()
keydata() = {'RSAPrivateKey' | 'DSAPrivateKey' | 'ECPrivateKey' | 'PrivateKeyInfo', binary()}
name() = atom()
notification() = binary()
path() = string()
proxy_info() = #{type := connect, host := host(), port := inet:port_number(), username => iodata(), password => iodata()}
state() = #{connection := connection(), gun_pid => pid(), gun_monitor => reference(), gun_connect_ref => reference(), client := pid(), backoff := non_neg_integer(), backoff_ceiling := non_neg_integer()}
type() = certdata | cert | token
await_tunnel_up/3 | |
await_up/3 | |
callback_mode/0 | |
certdata/1 | |
certfile/1 | |
close_connection/1 | Close the connection with APNs gracefully. |
code_change/4 | |
connected/3 | |
default_connection/2 | Builds a connection() map from the environment variables. |
down/3 | |
gun_pid/1 | Returns the gun's connection PID. |
host/1 | |
init/1 | |
keydata/1 | |
keyfile/1 | |
name/1 | |
open_common/3 | |
open_connection/3 | |
open_origin/3 | |
open_proxy/3 | |
port/1 | |
proxy_connect_to_origin/3 | |
push_notification/4 | Pushes notification to certificate APNs connection. |
push_notification/5 | Pushes notification to certificate APNs connection. |
start_link/2 | starts the gen_statem. |
type/1 | |
wait_apns_connection_up/1 | Waits until the APNS connection is up. |
await_tunnel_up(EventType::term(), EventContent::term(), StateData::term()) -> term()
await_up(EventType::term(), EventContent::term(), StateData::term()) -> term()
callback_mode() -> state_functions
certdata(X1::connection()) -> binary()
certfile(X1::connection()) -> path()
close_connection(ConnectionId::name() | pid()) -> ok
Close the connection with APNs gracefully
code_change(OldVsn::term() | {down, term()}, StateName, StateData, Extra::term()) -> {ok, StateName, StateData}
connected(EventType::term(), Event::term(), StateData::term()) -> term()
default_connection(X1::type(), ConnectionName::name()) -> connection()
Builds a connection() map from the environment variables.
down(EventType::term(), EventContent::term(), StateData::term()) -> term()
gun_pid(ConnectionId::name() | pid()) -> pid()
Returns the gun's connection PID. This function is only used in tests.
host(X1::connection()) -> host()
init(X1::{connection(), pid()}) -> {ok, open_connection, State::state(), {next_event, internal, init}}
keydata(X1::connection()) -> keydata()
keyfile(X1::connection()) -> path()
name(X1::connection()) -> name()
open_common(X1::term(), X2::term(), StateData::term()) -> term()
open_connection(X1::term(), X2::term(), StateData::term()) -> term()
open_origin(X1::term(), X2::term(), StateData::term()) -> term()
open_proxy(X1::term(), X2::term(), StateData::term()) -> term()
port(X1::connection()) -> inet:port_number()
proxy_connect_to_origin(X1::term(), X2::term(), StateData::term()) -> term()
push_notification(ConnectionId::name() | pid(), DeviceId::apns:device_id(), Notification::notification(), Headers::apns:headers()) -> apns:response() | {error, not_connection_owner}
Pushes notification to certificate APNs connection.
push_notification(ConnectionId::name() | pid(), Token::apns:token(), DeviceId::apns:device_id(), Notification::notification(), Headers::apns:headers()) -> apns:response() | {error, not_connection_owner}
Pushes notification to certificate APNs connection.
start_link(Connection::connection(), Client::pid()) -> {ok, Pid::pid()} | ignore | {error, Reason::term()}
starts the gen_statem
type(X1::connection()) -> type()
wait_apns_connection_up(Server::pid()) -> ok
Waits until the APNS connection is up.
Note that this function does not need to be called before sending push notifications, since they will be queued up and sent when the connection is established.Generated by EDoc