aboutsummaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorJakob Pfender <jpfender@zedat.fu-berlin.de>2010-10-14 10:30:13 +0200
committerJakob Pfender <jpfender@zedat.fu-berlin.de>2010-10-14 10:30:13 +0200
commit37a33b4ef3a8d9c4a1b984e44bfe5be03525c302 (patch)
treee934bba4f1d652df02f099a8df07715cfe744679 /client
parent9b5db7ab37a4a2527d523ff39bb0c5525553119e (diff)
downloaderlang-37a33b4ef3a8d9c4a1b984e44bfe5be03525c302.tar.gz
erlang-37a33b4ef3a8d9c4a1b984e44bfe5be03525c302.tar.xz
erlang-37a33b4ef3a8d9c4a1b984e44bfe5be03525c302.zip
client-side voting
Diffstat (limited to 'client')
-rw-r--r--client/client.erl30
1 files changed, 30 insertions, 0 deletions
diff --git a/client/client.erl b/client/client.erl
index d0bae4c..a287af3 100644
--- a/client/client.erl
+++ b/client/client.erl
@@ -74,3 +74,33 @@ handle({change_state, NewState}, _) ->
handle(Cmd, Server) ->
{{error, {unknown_command, Cmd}}, Server}.
+
+%queries the server for the current votes this client possesses
+getVotes() ->
+ rpc(Server, getVotes, self()),
+ receive
+ Msg ->
+ Msg
+ end.
+
+%positive vote, increments the votes for {Artist, Title} by one
+vote(Artist, Title) ->
+ rpc(Server, vote, [Artist, Title]),
+ receive
+ {_, ok, Msg} ->
+ Msg;
+ {_, error, Msg} ->
+ {error, Msg}
+ end.
+
+%negative vote, decrements the votes for {Artist, Title} by one
+devote(Artist, Title) ->
+ rpc(Server, devote, [Artist, Title]),
+ receive
+ {_, ok, Msg} ->
+ Msg;
+ {_, error, Msg} ->
+ {error, Msg}
+ end.
+
+