From e70fe72c584a8798f5bd7024949c32de5ce90aa0 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 14 Oct 2010 14:10:10 +0200 Subject: implemented some functions on the server --- server/client.erl | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/server/client.erl b/server/client.erl index ce7c99b..333df4a 100644 --- a/server/client.erl +++ b/server/client.erl @@ -10,32 +10,52 @@ start(Node) -> case server:rpc(Client, {change_state, Server}) of {ok} -> {ok, Client}; - _ -> - {error, unknown_error} + Why -> + {error, {unknown_error, Why}} end. loop(Client) -> receive list -> - Client ! {ok, {foo}}, - loop(Client); + try media:all() of + Result -> + Client ! {ok, Result} + catch + _: Why -> + Client ! {error, Why} + end; get_votes -> - Client ! {ok, media:getVotes(Client)}, - loop(Client); + try media:getVotes(Client) of + Result -> + Client ! {ok, Result} + catch + _: Why -> + Client ! {error, Why} + end; {vote, Artist, Title} -> - Client ! media:vote(Artist, Title), - loop(Client); + try media:vote(Artist, Title) of + Result -> + Client ! {ok, Result} + catch + _: Why -> + Client ! {error, Why} + end; {devote, Artist, Title} -> - Client ! media:devote(Artist, Title), - loop(Client); + try media:devote(Artist, Title) of + Result -> + Client ! {ok, Result} + catch + _: Why -> + Client ! {error, Why} + end; Cmd -> - Client ! {error, {unknown_command, Cmd}}, - loop(Client) - end. + Client ! {error, {unknown_command, Cmd}} + end, + loop(Client). register(Client, {Name, Password}) -> dis ! {Client, {register, {Name, Password}}}. -- cgit v1.2.3