123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- -module(syn_test_gen_server).
- -behaviour(gen_server).
- -export([start_link/1]).
- -export([ping/1]).
- -export([stop/1]).
- -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
- start_link(Tuple) ->
- gen_server:start_link(Tuple, ?MODULE, [], []).
- ping(Tuple) ->
- gen_server:call(Tuple, ping).
- stop(Tuple) ->
- gen_server:cast(Tuple, stop).
- init(State) ->
- {ok, State}.
- handle_call(ping, _From, State) ->
- {reply, pong, State}.
- handle_cast(stop, State) ->
- {stop, normal, State};
- handle_cast(_Msg, State) ->
- {noreply, State}.
- handle_info({SenderPid, send_ping}, State) ->
- SenderPid ! reply_pong,
- {noreply, State}.
- terminate(_Reason, _State) ->
- ok.
- code_change(_OldVsn, State, _Extra) ->
- {ok, State}.
|