diff options
-rw-r--r-- | client/client.erl | 10 | ||||
-rw-r--r-- | server/dispatcher.erl | 12 |
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}}}. |