Guest User

Untitled

a guest
Jun 2nd, 2019
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.80 KB | None | 0 0
  1. -module(oka_oprek_bgensrv).
  2. -behaviour(gen_server).
  3.  
  4. %% API
  5. -export([stop/0, start_link/0, hello/0]).
  6. -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
  7. -record(state, {dummy}).
  8.  
  9. start_link() ->
  10.   gen_server:start_link({local, bgensrv}, ?MODULE, ["Oka Prinarjaya"], []).
  11.  
  12. stop() ->
  13.   gen_server:call(bgensrv, stop).
  14.  
  15. hello() ->
  16.   gen_server:call(bgensrv, hello).
  17.  
  18. init(ApaAja) ->
  19.   {ok, #state{dummy=ApaAja}}.
  20.  
  21. handle_call(stop, _From, State) ->
  22.   {stop, normal, State};
  23.  
  24. handle_call(hello, From, State) ->
  25.   {reply, {ok, 'hello_from_b', From}, State}.
  26.  
  27. handle_cast(_Msg, State) ->
  28.   {noreply, State}.
  29.  
  30. handle_info(_Info, State) ->
  31.   {noreply, State}.
  32.  
  33. terminate(_Reason, _State) ->
  34.   ok.
  35.  
  36. code_change(_OldVsn, State, _Extra) ->
  37.   {ok, State}.
Advertisement
Add Comment
Please, Sign In to add comment