mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
now using p1_fsm behaviour in c2s FSM (EJAB-1173)
SVN Revision: 2937
This commit is contained in:
parent
479e5cb107
commit
e31b2582b6
@ -28,7 +28,9 @@
|
|||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
-update_info({update, 0}).
|
-update_info({update, 0}).
|
||||||
|
|
||||||
-behaviour(gen_fsm).
|
-define(GEN_FSM).
|
||||||
|
|
||||||
|
-behaviour(?GEN_FSM).
|
||||||
|
|
||||||
%% External exports
|
%% External exports
|
||||||
-export([start/2,
|
-export([start/2,
|
||||||
@ -108,8 +110,8 @@
|
|||||||
|
|
||||||
%% Module start with or without supervisor:
|
%% Module start with or without supervisor:
|
||||||
-ifdef(NO_TRANSIENT_SUPERVISORS).
|
-ifdef(NO_TRANSIENT_SUPERVISORS).
|
||||||
-define(SUPERVISOR_START, gen_fsm:start(ejabberd_c2s, [SockData, Opts],
|
-define(SUPERVISOR_START, ?GEN_FSM:start(ejabberd_c2s, [SockData, Opts],
|
||||||
?FSMOPTS)).
|
fsm_limit_opts() ++ ?FSMOPTS)).
|
||||||
-else.
|
-else.
|
||||||
-define(SUPERVISOR_START, supervisor:start_child(ejabberd_c2s_sup,
|
-define(SUPERVISOR_START, supervisor:start_child(ejabberd_c2s_sup,
|
||||||
[SockData, Opts])).
|
[SockData, Opts])).
|
||||||
@ -155,22 +157,23 @@ start(SockData, Opts) ->
|
|||||||
?SUPERVISOR_START.
|
?SUPERVISOR_START.
|
||||||
|
|
||||||
start_link(SockData, Opts) ->
|
start_link(SockData, Opts) ->
|
||||||
gen_fsm:start_link(ejabberd_c2s, [SockData, Opts], ?FSMOPTS).
|
?GEN_FSM:start_link(ejabberd_c2s, [SockData, Opts],
|
||||||
|
fsm_limit_opts() ++ ?FSMOPTS).
|
||||||
|
|
||||||
socket_type() ->
|
socket_type() ->
|
||||||
xml_stream.
|
xml_stream.
|
||||||
|
|
||||||
%% Return Username, Resource and presence information
|
%% Return Username, Resource and presence information
|
||||||
get_presence(FsmRef) ->
|
get_presence(FsmRef) ->
|
||||||
gen_fsm:sync_send_all_state_event(FsmRef, {get_presence}, 1000).
|
?GEN_FSM:sync_send_all_state_event(FsmRef, {get_presence}, 1000).
|
||||||
|
|
||||||
|
|
||||||
%%TODO: for debug only
|
%%TODO: for debug only
|
||||||
get_state(FsmRef) ->
|
get_state(FsmRef) ->
|
||||||
gen_fsm:sync_send_all_state_event(FsmRef, get_state, 1000).
|
?GEN_FSM:sync_send_all_state_event(FsmRef, get_state, 1000).
|
||||||
|
|
||||||
stop(FsmRef) ->
|
stop(FsmRef) ->
|
||||||
gen_fsm:send_event(FsmRef, closed).
|
?GEN_FSM:send_event(FsmRef, closed).
|
||||||
|
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% Callback functions from gen_fsm
|
%%% Callback functions from gen_fsm
|
||||||
@ -241,7 +244,7 @@ init([{SockMod, Socket}, Opts]) ->
|
|||||||
|
|
||||||
%% Return list of all available resources of contacts,
|
%% Return list of all available resources of contacts,
|
||||||
get_subscribed(FsmRef) ->
|
get_subscribed(FsmRef) ->
|
||||||
gen_fsm:sync_send_all_state_event(FsmRef, get_subscribed, 1000).
|
?GEN_FSM:sync_send_all_state_event(FsmRef, get_subscribed, 1000).
|
||||||
|
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
@ -851,7 +854,7 @@ session_established({xmlstreamelement, El}, StateData) ->
|
|||||||
session_established(timeout, StateData) ->
|
session_established(timeout, StateData) ->
|
||||||
%% TODO: Options must be stored in state:
|
%% TODO: Options must be stored in state:
|
||||||
Options = [],
|
Options = [],
|
||||||
proc_lib:hibernate(gen_fsm, enter_loop,
|
proc_lib:hibernate(?GEN_FSM, enter_loop,
|
||||||
[?MODULE, Options, session_established, StateData]),
|
[?MODULE, Options, session_established, StateData]),
|
||||||
fsm_next_state(session_established, StateData);
|
fsm_next_state(session_established, StateData);
|
||||||
|
|
||||||
@ -2079,3 +2082,11 @@ check_from(El, FromJID) ->
|
|||||||
'invalid-from'
|
'invalid-from'
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
fsm_limit_opts() ->
|
||||||
|
case ejabberd_config:get_local_option(max_fsm_queue) of
|
||||||
|
N when is_integer(N) ->
|
||||||
|
[{max_queue, N}];
|
||||||
|
_ ->
|
||||||
|
[]
|
||||||
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user