Hello everybody,<br><br>I have two files, main.erl which control a finite state machine (FSM) with a gen_fsm behavior.<br>The FSM is also able to received incoming data from a socket for certain state (using the handle_info method).<br>
<br>The question is how the main program can wait and know the next state after handle_info callback is done by the gen_fsm....<br>because, according to the rawdata received the system move to another state and main.erl must know this new state to send specifics events....<br>
<br>Maybe more easy to understand with a small illustration<br><br>main.erl<br> {ok, FSMPid} = myfsm:start_link(...),<br> ok = gen_fsm:sync_send_event(FSMPid, event1) <br> % => will move the FSM to state_5 where we are waiting socket incoming data<br>
% these data will be handle by "handle_info({tcp, _Socket, RawData}, state_5, StateData)"<br> % depending on the received socket rawdata, we will change the state of the FSM <br>
<br> <br> => How can I wait handle_info has finished ?<br> => How can I get the state ?<br>
(for this last question, I think I can just send a
send_all_state(FSMPid, current_state) for example and return the
StateName<br>
<br> program will continue like this:<br> case StateName of<br> state_13 -> send another event<br> ....<br><br><br> <br> <br><br>thanks for help,<br><br>Arnaud<br> <br> <br><br> <br><br>
<br><br>