diff options
Diffstat (limited to '')
-rw-r--r-- | client/client.erl | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/client/client.erl b/client/client.erl index aab0b4e..ec44401 100644 --- a/client/client.erl +++ b/client/client.erl @@ -58,41 +58,23 @@ list() -> {error, not_logged_in} end. -handle(list, Server) -> - Server ! list, +send_to_server(Cmd, Server) -> + Server ! cmd, receive {ok, Msg} -> {Msg, Server}; Msg -> {Msg, Server} - end; + end. +handle(list, Server) -> + send_to_server(list, Server); handle(get_votes, Server) -> - Server ! get_votes, - receive - {ok, Msg} -> - {Msg, Server}; - Msg -> - {Msg, Server} - end; - + send_to_server(get_votes, Server); handle({vote, Artist, Title}, Server) -> - Server ! {vote, Artist, Title}, - receive - {ok, Msg} -> - {Msg, Server}; - Msg -> - {Msg, Server} - end; - + send_to_server({vote, Artist, Title}, Server); handle({devote, Artist, Title}, Server) -> - Server ! {vote, Artist, Title}, - receive - {ok, Msg} -> - {Msg, Server}; - Msg -> - {Msg, Server} - end; + send_to_server({devote, Artist, Title}, Server); handle({change_state, NewState}, _) -> {{ok}, NewState}; |