aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer/test/client.erl
blob: 90b72d3f8fce9e7955dc4e5aa4c1f6c318dd25fb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-module(client).
-compile(export_all).

init(Node) ->
    application:start(runtime_tools),
    net_kernel:connect_node(Node).

init() ->
    init(server_node()).

restart() ->
    init:restart().

server_node() ->
    {ok,HostName} = inet:gethostname(),
    list_to_atom("server@" ++ HostName).

get() ->
    erlang:send({server,server_node()}, {get,self()}),
    receive Data -> Data
    after 1000   -> no_reply
    end.

put(Thing) ->
    erlang:send({server,server_node()}, {put,self(),Thing}),
    receive ok -> timer:sleep(2), ok
    after 1000 -> no_reply
    end.