aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/examples/code/client_cb.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2017-08-19 12:36:27 +0200
committerAnders Svensson <[email protected]>2017-08-19 13:15:34 +0200
commitbc86d93f4c842487e1c1ea37ba743d5fe9169c58 (patch)
tree1aa3ef639572889f2e250f8ed1ac9c45ec1a507e /lib/diameter/examples/code/client_cb.erl
parentfa233bb7bc4f37632166c468a0381e695433c318 (diff)
downloadotp-bc86d93f4c842487e1c1ea37ba743d5fe9169c58.tar.gz
otp-bc86d93f4c842487e1c1ea37ba743d5fe9169c58.tar.bz2
otp-bc86d93f4c842487e1c1ea37ba743d5fe9169c58.zip
Use map decoding in example client
As introduced in commit 1b3b64af and adjusted in commit e0603ba1. There's nothing client-specific about it, but keep the record format in the server example for the sake of coverage.
Diffstat (limited to 'lib/diameter/examples/code/client_cb.erl')
-rw-r--r--lib/diameter/examples/code/client_cb.erl29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/diameter/examples/code/client_cb.erl b/lib/diameter/examples/code/client_cb.erl
index ed1d3b9b7b..af2d4d6da7 100644
--- a/lib/diameter/examples/code/client_cb.erl
+++ b/lib/diameter/examples/code/client_cb.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2010-2016. All Rights Reserved.
+%% Copyright Ericsson AB 2010-2017. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
@@ -55,21 +55,18 @@ prepare_request(#diameter_packet{msg = ['RAR' = T | Avps]}, _, {_, Caps}) ->
origin_realm = {OR, DR}}
= Caps,
- {send, [T, {'Origin-Host', OH},
- {'Origin-Realm', OR},
- {'Destination-Host', DH},
- {'Destination-Realm', DR}
- | Avps]};
-
-prepare_request(#diameter_packet{msg = Rec}, _, {_, Caps}) ->
- #diameter_caps{origin_host = {OH, DH},
- origin_realm = {OR, DR}}
- = Caps,
-
- {send, Rec#diameter_base_RAR{'Origin-Host' = OH,
- 'Origin-Realm' = OR,
- 'Destination-Host' = DH,
- 'Destination-Realm' = DR}}.
+ {send, [T | if is_map(Avps) ->
+ Avps#{'Origin-Host' => OH,
+ 'Origin-Realm' => OR,
+ 'Destination-Host' => DH,
+ 'Destination-Realm' => DR};
+ is_list(Avps) ->
+ [{'Origin-Host', OH},
+ {'Origin-Realm', OR},
+ {'Destination-Host', DH},
+ {'Destination-Realm', DR}
+ | Avps]
+ end]}.
%% prepare_retransmit/3