aboutsummaryrefslogtreecommitdiffstats
path: root/client/client.erl
diff options
context:
space:
mode:
authorMarco Ziener <mziener@lavabit.com>2010-10-13 15:27:56 +0200
committerMarco Ziener <mziener@lavabit.com>2010-10-13 15:27:56 +0200
commit4ba5338d3279cd75106aa96810b91e35e692a49f (patch)
tree2d5f3a2a37c43f1b0461689ac911f49c992b83cd /client/client.erl
parent86442139036c7d1b8be83b60d43197a618ac93c6 (diff)
parentd1c3af4f92f169853262dcc7f6c58bdd287c21ca (diff)
downloaderlang-4ba5338d3279cd75106aa96810b91e35e692a49f.tar.gz
erlang-4ba5338d3279cd75106aa96810b91e35e692a49f.tar.xz
erlang-4ba5338d3279cd75106aa96810b91e35e692a49f.zip
Merge branch 'master' of ssh://git.animux.de/erlang
Diffstat (limited to 'client/client.erl')
-rw-r--r--client/client.erl31
1 files changed, 31 insertions, 0 deletions
diff --git a/client/client.erl b/client/client.erl
new file mode 100644
index 0000000..9781b74
--- /dev/null
+++ b/client/client.erl
@@ -0,0 +1,31 @@
+-module(client).
+-export([register/3, login/3, list/0, logged_in/1]).
+
+register(Server, Name, Password) ->
+ rpc:call(Server, client, register, [self(), {Name, Password}]),
+ receive
+ {_, ok, Msg} ->
+ Msg;
+ {_, error, Msg} ->
+ Msg
+ end.
+
+login(Server, Name, Password) ->
+ rpc:call(Server, client, login, [self(), {Name, Password}]),
+ receive
+ {_, ok, {ok, {logged_in, Client}}} ->
+ register(cli, spawn(client, logged_in, [Client]));
+ {_, error, Msg} ->
+ Msg
+ end.
+
+list() ->
+ cli ! {list}.
+
+logged_in(Client) ->
+ receive
+ {list} ->
+ Client ! {list};
+ _ ->
+ logged_in(Client)
+ end.