1 |
|
-module(mongoose_session). |
2 |
|
|
3 |
|
-export([get_info/1]). |
4 |
|
-export([get_info/3]). |
5 |
|
-export([set_info/3]). |
6 |
|
-export([get_resource/1]). |
7 |
|
|
8 |
|
-ignore_xref([get_info/1, set_info/3]). |
9 |
|
|
10 |
|
-include("session.hrl"). |
11 |
|
|
12 |
|
-spec get_info(ejabberd_sm:session()) -> ejabberd_sm:info(). |
13 |
|
get_info(#session{info = Info}) -> |
14 |
:-( |
Info. |
15 |
|
|
16 |
|
-spec get_info(ejabberd_sm:session(), ejabberd_sm:info_key(), any()) -> any(). |
17 |
|
get_info(#session{info = Info}, Key, Default) -> |
18 |
3360 |
case maps:is_key(Key, Info) of |
19 |
105 |
true -> {Key, maps:get(Key, Info)}; |
20 |
3255 |
false -> Default |
21 |
|
end. |
22 |
|
|
23 |
|
-spec set_info(ejabberd_sm:session(), ejabberd_sm:info_key(), any()) -> ejabberd_sm:session(). |
24 |
|
set_info(#session{info = Info} = Session, Key, Value) -> |
25 |
:-( |
Session#session{info = maps:put(Key, Value, Info)}. |
26 |
|
|
27 |
|
-spec get_resource(ejabberd_sm:session()) -> jid:lresource(). |
28 |
|
get_resource(#session{usr = {_U, _S, R}}) -> |
29 |
10 |
R. |