From d1c3af4f92f169853262dcc7f6c58bdd287c21ca Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 13 Oct 2010 15:03:09 +0200 Subject: some progress --- client/client.erl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 client/client.erl (limited to 'client') 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. -- cgit v1.2.3