本文主要是介绍erlang客户端程序学习(三),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
erlang gen_fsm模式模板:%%File Name:pro_ureq.erl %%Using:This module is used for processing user's request which is "MASTER_VM_START". %%The command is used for select a NC. -module(pro_ureq). -behaviour(gen_fsm). -export([start/1]). -export([message/1]). -export([init/1, nc_unvailable/2, nc_available/2, code_change/4, handle_info/3]). -export([handle_event/3, terminate/3, handle_sync_event/4]). start(AllResource) -> gen_fsm:start_link({local, pro_ureq}, pro_ureq, AllResource, []). message(Msg) -> gen_fsm:send_event(pro_ureq, {button, Msg}). %%%Callback function nc_unvailable({button, Msg}, {_SoFar, AllResource}) -> io:format("~p ~p~n",[AllResource, Msg]), {next_state, nc_available, {[], AllResource}}. nc_available(A, State) -> io:format("ssssssssssssssss~p~n", [A]), {next_state, nc_unvailable, State}. init(AllResource) -> {ok, nc_unvailable, {[], AllResource}}. code_change(_OldVsn, StateName, StateData, _Extra) -> {ok, StateName, StateData}. handle_info(Info, StateName, StateData) -> %%%%return Result {Info, StateName, StateData}. handle_event(Event, StateName, StateData) -> %%%%return Result {Event, StateName, StateData}. terminate(_Reason, _StateName, _StateData) -> ok. handle_sync_event(Event, From, StateName, StateData) -> %%%%return Result {Event, From, StateName, StateData}. |
相关热门文章
- linux 常见服务端口
- xmanager 2.0 for linux配置
- 【ROOTFS搭建】busybox的httpd...
- openwrt中luci学习笔记
- 什么是shell
- linux dhcp peizhi roc
- 关于Unix文件的软链接
- 求教这个命令什么意思,我是新...
- sed -e "/grep/d" 是什么意思...
- 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
评论热议
这篇关于erlang客户端程序学习(三)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!