aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wittig <michael.wittig@fu-berlin.de>2010-10-14 17:49:42 +0200
committerMichael Wittig <michael.wittig@fu-berlin.de>2010-10-14 17:49:42 +0200
commitf2164544210f511664ed7186107789ec55ec3edf (patch)
tree8acd9dccb05b442c8dc601928c1e70e8d6a7cf18
parent5697eac2876904546954e48577763713c03eb935 (diff)
downloaderlang-f2164544210f511664ed7186107789ec55ec3edf.tar.gz
erlang-f2164544210f511664ed7186107789ec55ec3edf.tar.xz
erlang-f2164544210f511664ed7186107789ec55ec3edf.zip
finally finished, need to be read again
-rw-r--r--server/cldb.erl8
-rw-r--r--server/media.erl11
2 files changed, 9 insertions, 10 deletions
diff --git a/server/cldb.erl b/server/cldb.erl
index 0602b7d..d514ff9 100644
--- a/server/cldb.erl
+++ b/server/cldb.erl
@@ -59,3 +59,11 @@ incVote(User) ->
check_rights(User) ->
{_, _, Rights} = ask(User, '_'),
Rights.
+
+% after a song every client gets on more vote
+give_votes([Head|Rest]) ->
+ User = Head#user.name,
+ incVote(User),
+ give_votes(Rest);
+give_votes([]) -> ok.
+
diff --git a/server/media.erl b/server/media.erl
index 83e7513..80a3fea 100644
--- a/server/media.erl
+++ b/server/media.erl
@@ -112,20 +112,11 @@ play(Artist, Title) ->
io:format("playing: ~s, Artist: ~s~n", [Title, Artist]),
receive
- {Port, {exit_status, 0}} -> give_votes(cldb:ask("_","_")), start_playing();
+ {Port, {exit_status, 0}} -> cldb:give_votes(cldb:ask("_","_")), start_playing();
{Port, {exit_status, S}} -> throw({commandfailed, S})
end.
-% after a song every client gets on more vote
-give_votes([Head|Rest]) ->
- User = Head#user.name,
- Pwd = Head#user.passwd,
- cldb:incVote(User, Pwd),
- giveVotes(Rest);
-give_Votes([]) -> ok.
-
-
% Of course we need a query to find out what the highest voted track is.
% We accomplish this by requesting all the records from the database and then iterate over them, just taking a look at the vote
% variable, so it is like a list of integers. In case no tracks were voted for we just take the first track we found and play it. Of course this song is locked afterwards so a different one will be chosen.