forked from erlang/signerl
TCO needs to know the PID of the user to deliver incoming BEGIN
If TCO detects an incoming BEGIN, it starts tcap_transaction_sup which in turn start dha_fsm and ism_fsm, who both need to know to whom to send the new components We nw send those to the Pid that was set by the user using gen_server:call(TCOpid, set_usap). This is most likely not the right approach, as most apps will probably want to create a new process for each dialogue. Needs improvement later.
This commit is contained in:
parent
db99b66859
commit
ce41e7f2a9
|
@ -183,7 +183,7 @@ behaviour_info(Other) ->
|
||||||
-include("tcap.hrl").
|
-include("tcap.hrl").
|
||||||
-include("sccp.hrl").
|
-include("sccp.hrl").
|
||||||
|
|
||||||
-record(state, {supervisor, module, ext_state}).
|
-record(state, {supervisor, module, ext_state, usap}).
|
||||||
|
|
||||||
%%----------------------------------------------------------------------
|
%%----------------------------------------------------------------------
|
||||||
%% The gen_server call backs
|
%% The gen_server call backs
|
||||||
|
@ -210,10 +210,12 @@ init([Sup, Module, Args]) when is_list(Args) ->
|
||||||
%% @hidden
|
%% @hidden
|
||||||
%%
|
%%
|
||||||
% assign a new dialogue ID
|
% assign a new dialogue ID
|
||||||
handle_call(dialogueID, From, State) ->
|
handle_call(dialogueID, _FromRef, State) ->
|
||||||
{reply, new_tid(), State};
|
{reply, new_tid(), State};
|
||||||
|
handle_call(set_usap, {From, Ref}, State) ->
|
||||||
|
{reply, ok, State#state{usap = From}};
|
||||||
% shutdown the server
|
% shutdown the server
|
||||||
handle_call(stop, _From, State) ->
|
handle_call(stop, _FromRef, State) ->
|
||||||
{stop, shutdown, ok, State};
|
{stop, shutdown, ok, State};
|
||||||
handle_call({local_new_trans, OTID}, {Usap, Ref}, State) ->
|
handle_call({local_new_trans, OTID}, {Usap, Ref}, State) ->
|
||||||
% Create a Transaction State Machine (TSM)
|
% Create a Transaction State Machine (TSM)
|
||||||
|
@ -649,14 +651,16 @@ get_start(dialogue, DialogueID, State) ->
|
||||||
end;
|
end;
|
||||||
get_start(in_transaction, TransactionID, State) ->
|
get_start(in_transaction, TransactionID, State) ->
|
||||||
Module = State#state.module,
|
Module = State#state.module,
|
||||||
|
Usap = State#state.usap,
|
||||||
case erlang:function_exported(Module, start_transaction, 1) of
|
case erlang:function_exported(Module, start_transaction, 1) of
|
||||||
true ->
|
true ->
|
||||||
Module:start_transaction(TransactionID, State#state.ext_state);
|
Module:start_transaction(TransactionID, State#state.ext_state);
|
||||||
false ->
|
false ->
|
||||||
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
SendFun = fun(P) -> Module:send_primitive(P, State#state.ext_state) end,
|
||||||
StartDHA = get_start(dialogue, TransactionID, State),
|
StartDHA = get_start(dialogue, TransactionID, State),
|
||||||
StartArgs = [TransactionID, SendFun, StartDHA],
|
% FIXME: use StartDHA and pass it into transaction_sup->tsm_fsm
|
||||||
{gen_fsm, start_link, [tcap_tsm_fsm, StartArgs, []]}
|
StartArgs = [SendFun, Usap, TransactionID, self()],
|
||||||
|
{supervisor, start_link, [tcap_transaction_sup, StartArgs]}
|
||||||
end;
|
end;
|
||||||
get_start(out_transaction, [TransactionID, Usap], State) when is_record(State, state) ->
|
get_start(out_transaction, [TransactionID, Usap], State) when is_record(State, state) ->
|
||||||
#state{module = Module, supervisor = Sup} = State,
|
#state{module = Module, supervisor = Sup} = State,
|
||||||
|
|
Loading…
Reference in New Issue