Skip to content

Commit

Permalink
pattern match instead of maps:get
Browse files Browse the repository at this point in the history
  • Loading branch information
dcy committed May 14, 2017
1 parent 89cb602 commit 798e431
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/apns_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,14 @@ handle_call( {push_notification, DeviceId, Notification, Headers}
, _From
, State) ->
#{connection := Connection, gun_connection := GunConn} = State,
Timeout = maps:get(timeout, Connection),
#{timeout := Timeout} = Connection,
Response = push(GunConn, DeviceId, Headers, Notification, Timeout),
{reply, Response, State};
handle_call( {push_notification, Token, DeviceId, Notification, HeadersMap}
, _From
, State) ->
#{connection := Connection, gun_connection := GunConn} = State,
Timeout = maps:get(timeout, Connection),
#{timeout := Timeout} = Connection,
Headers = add_authorization_header(HeadersMap, Token),
Response = push(GunConn, DeviceId, Headers, Notification, Timeout),
{reply, Response, State};
Expand Down Expand Up @@ -223,7 +223,7 @@ handle_info(reconnect, State) ->
, backoff_ceiling := Ceiling
} = State,
GunConn = open_gun_connection(Connection),
Timeout = maps:get(timeout, Connection),
#{timeout := Timeout} = Connection,
case gun:await_up(GunConn, Timeout) of
{ok, http2} ->
Client ! {connection_up, self()},
Expand All @@ -237,7 +237,7 @@ handle_info(reconnect, State) ->
end;
handle_info(timeout, #{connection := Connection, gun_connection := GunConn,
client := Client} = State) ->
Timeout = maps:get(timeout, Connection),
#{timeout := Timeout} = Connection,
case gun:await_up(GunConn, Timeout) of
{ok, http2} ->
Client ! {connection_up, self()},
Expand Down

0 comments on commit 798e431

Please sign in to comment.