diff options
Diffstat (limited to '')
-rw-r--r-- | server/client.erl | 6 | ||||
-rw-r--r-- | server/dispatcher.erl | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/server/client.erl b/server/client.erl index 7139e67..9d778f0 100644 --- a/server/client.erl +++ b/server/client.erl @@ -2,12 +2,14 @@ -export([start/1, loop/1, register/2, login/2]). start(Client) -> - spawn(client, loop, Client). + process_flag(trap_exit, true), + spawn(client, loop, [Client]). loop(Client) -> receive {list} -> - Client ! {ok, media ! {all}}; + Client ! {ok, foo}, + loop(Client); true -> Client ! {error, unknown_command}, diff --git a/server/dispatcher.erl b/server/dispatcher.erl index 4cef276..390f9e5 100644 --- a/server/dispatcher.erl +++ b/server/dispatcher.erl @@ -2,10 +2,18 @@ -export([start/0, init/0, handle/3]). start() -> - server:start(dis, dispatcher). code:purge(server), code:load_abs("../common/server"), + case server:start(dis, dispatcher) of + true -> + io:format("Server started... ~n"), + true; + _ -> + io:format("Error starting server! Exiting.~n"), + exit(1) + end. + init() -> dict:new(). @@ -14,6 +22,7 @@ handle(_, {register, {User, Password}}, Dict) -> {ok, _}-> {{error, duplicated_user}, Dict}; _ -> + io:format("User created: ~s~n", [User]), {{ok, user_created}, dict:store(User, Password, Dict)} end; |