aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2010-10-15 11:51:49 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2010-10-15 11:51:49 +0200
commitb91af95d1ef5fc893c3db784e9ab6df2c28b4638 (patch)
tree2ac3152cce9a22ec1faf6a02c7d2ac4b3c1963f6
parent3c11d5040d2d38616a51aa562ac94e251aa69f6a (diff)
downloaderlang-b91af95d1ef5fc893c3db784e9ab6df2c28b4638.tar.gz
erlang-b91af95d1ef5fc893c3db784e9ab6df2c28b4638.tar.xz
erlang-b91af95d1ef5fc893c3db784e9ab6df2c28b4638.zip
removed register/2 and login/2 from dispatcher (now direct call to dis)
Diffstat (limited to '')
-rw-r--r--client/client.erl10
-rw-r--r--server/dispatcher.erl12
2 files changed, 6 insertions, 16 deletions
diff --git a/client/client.erl b/client/client.erl
index 43dbfc6..ee9421f 100644
--- a/client/client.erl
+++ b/client/client.erl
@@ -15,9 +15,9 @@ buildNode(Server) ->
%% build the node string of the server by using the hostname
list_to_atom("distributed_music_system_main_node@" ++ Server).
-rpc(Server, Function, Params) ->
- %% shortcut for calling a function from the server
- rpc:call(buildNode(Server), dispatcher, Function, Params).
+rpc(Server, Params) ->
+ %% shortcut for sending something to the dispatcher on the server
+ {dis, buildNode(Server)} ! {self(), Params}.
register(Server, Name, Password) ->
%% check if client is not logged in (if client is logged in,
@@ -25,7 +25,7 @@ register(Server, Name, Password) ->
try checkLogin(false) of
_ ->
%% register a new user account on the server
- rpc(Server, register, [self(), {Name, Password}])
+ rpc(Server, {register, {Name, Password}})
catch
{error, login_state} ->
{error, logged_in}
@@ -52,7 +52,7 @@ login(Server, Name, Password) ->
try checkLogin(false) of
_ ->
%% login to the server
- rpc(Server, login, [self(), {node(), Name, Password}]),
+ rpc(Server, {login, {node(), Name, Password}}),
receive
%% the server returns the Pid of the process on the
%% client, that should handle the communication
diff --git a/server/dispatcher.erl b/server/dispatcher.erl
index a0a0459..08b19ec 100644
--- a/server/dispatcher.erl
+++ b/server/dispatcher.erl
@@ -1,5 +1,5 @@
-module(dispatcher).
--export([start/0, handle/2, register/2, login/2]).
+-export([start/0, handle/2]).
checkUserExists([_|_]) ->
%% helper function to check if given array contains at least one element
@@ -74,13 +74,3 @@ handle({'EXIT', From, _}, State) ->
handle(Cmd, State) ->
%% standard command to find invalid commands and emit an error
{{error, {unknown_command, Cmd}}, State}.
-
-register(Client, {Name, Password}) ->
- %% forward the register messages to the dispatcher (called form
- %% the client)
- dis ! {Client, {register, {Name, Password}}}.
-
-login(Client, {Node, Name, Password}) ->
- %% forward the login messages to the dispatcher (called form the
- %% client)
- dis ! {Client, {login, {Node, Name, Password}}}.