1 |
|
%%% @doc A proxy interface module between the main mod_bosh module and the backend modules. |
2 |
|
%%% There is only one backend implementation (mnesia), so the backend module is global. |
3 |
|
-module(mod_bosh_backend). |
4 |
|
|
5 |
|
-export([start/1, |
6 |
|
create_session/1, |
7 |
|
delete_session/1, |
8 |
|
get_session/1, |
9 |
|
get_sessions/0, |
10 |
|
node_cleanup/1]). |
11 |
|
|
12 |
|
-define(MAIN_MODULE, mod_bosh). |
13 |
|
|
14 |
|
%% Callbacks |
15 |
|
|
16 |
|
-callback start() -> any(). |
17 |
|
|
18 |
|
-callback create_session(mod_bosh:session()) -> any(). |
19 |
|
|
20 |
|
-callback delete_session(mod_bosh:sid()) -> any(). |
21 |
|
|
22 |
|
-callback get_session(mod_bosh:sid()) -> [mod_bosh:session()]. |
23 |
|
|
24 |
|
-callback get_sessions() -> [mod_bosh:session()]. |
25 |
|
|
26 |
|
-callback node_cleanup(Node :: atom()) -> any(). |
27 |
|
|
28 |
|
%% API Functions |
29 |
|
|
30 |
|
-spec start(gen_mod:module_opts()) -> any(). |
31 |
|
start(Opts) -> |
32 |
104 |
mongoose_backend:init(global, ?MAIN_MODULE, [], Opts), |
33 |
104 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, []). |
34 |
|
|
35 |
|
-spec create_session(mod_bosh:session()) -> any(). |
36 |
|
create_session(Session) -> |
37 |
126 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, [Session]). |
38 |
|
|
39 |
|
-spec delete_session(mod_bosh:sid()) -> any(). |
40 |
|
delete_session(Sid) -> |
41 |
126 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, [Sid]). |
42 |
|
|
43 |
|
-spec get_session(mod_bosh:sid()) -> [mod_bosh:session()]. |
44 |
|
get_session(Sid) -> |
45 |
1942 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, [Sid]). |
46 |
|
|
47 |
|
-spec get_sessions() -> [mod_bosh:session()]. |
48 |
|
get_sessions() -> |
49 |
71 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, []). |
50 |
|
|
51 |
|
-spec node_cleanup(Node :: atom()) -> any(). |
52 |
|
node_cleanup(Node) -> |
53 |
8 |
mongoose_backend:call(global, ?MAIN_MODULE, ?FUNCTION_NAME, [Node]). |