diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-13 15:03:09 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-10-13 15:03:09 +0200 |
commit | d1c3af4f92f169853262dcc7f6c58bdd287c21ca (patch) | |
tree | bba848cd51d95658b6e88b3a77752a80e05c358e /client | |
parent | 3b4edbdddf8af55f63c22bb3ba80fffa46156dd2 (diff) | |
download | erlang-d1c3af4f92f169853262dcc7f6c58bdd287c21ca.tar.gz erlang-d1c3af4f92f169853262dcc7f6c58bdd287c21ca.tar.xz erlang-d1c3af4f92f169853262dcc7f6c58bdd287c21ca.zip |
some progress
Diffstat (limited to 'client')
-rw-r--r-- | client/client.erl | 31 |
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. |