1-module(gs1).
2-vsn(2).
3-behaviour(gen_server).
4
5-export([get_data/0, get_time/0]).
6-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
7	 terminate/2, code_change/3]).
8
9-record(state, {data, time}).
10
11get_data() ->
12    gen_server:call(gs1, get_data).
13
14get_time() ->
15    gen_server:call(gs1, get_time).
16
17init([Data]) ->
18    {ok, #state{data = Data, time = erlang:time()}}.
19
20handle_call(get_data, _From, State) ->
21    {reply, {ok, State#state.data}, State};
22handle_call(get_time, _From, State) ->
23    {reply, {ok, State#state.time}, State}.
24
25handle_cast(_Request, State) ->
26    {noreply, State}.
27
28handle_info(_Info, State) ->
29    {noreply, State}.
30
31terminate(_Reason, _State) ->
32    ok.
33
34code_change(1, {state, Data}, _Extra) ->
35    {ok, #state{data = Data, time = erlang:time()}}.
36