diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/client.erl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/client/client.erl b/client/client.erl index b1d8b0c..85f0e9d 100644 --- a/client/client.erl +++ b/client/client.erl @@ -72,3 +72,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. + + |