gen-fsm

Change gen_fsm state to a function in a different module

百般思念 提交于 2019-12-11 15:23:38
问题 We have a fairly large USSD application that uses Erlang's gen_fsm module to manage the menu options. The current version has a single menus_fsm.erl file that contains 5000+ lines gen_fsm related code. Our next version gives us an opportunity to split menus_fsm.erl into separate files to make it more maintainable in the future. In the old version, to display the help menu we do the following ( help_menu/1 gets called from code not shown that displays the main menu): -module(menus_fsm). %

Can I handle any received message in gen_fsm state callbacks?

我只是一个虾纸丫 提交于 2019-12-11 06:16:52
问题 I noticed that messages sent to the pid of a gen_fsm process are matched in the state callbacks as events. Is this just accidental or can I rely on this feature? Normally I would expect general messages sent to a gen_fsm to show up in the handle_info/3 callback and thought I would have to re-send it using gen_fsm:send_event. Does gen_fsm try to match the message first to the state callback and then allways with the handle_info/3 callback? Or only if it doesn't match a state callback clause?