From 7cd7907b9a4437c364200c0b455d753887080227 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 14 Oct 2010 15:19:19 +0200 Subject: added makefiles in the subdirs --- Makefile | 14 +++++++++++--- client/Makefile | 6 ++++++ server/Makefile | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 client/Makefile create mode 100644 server/Makefile diff --git a/Makefile b/Makefile index c309692..4b9fc1b 100644 --- a/Makefile +++ b/Makefile @@ -8,12 +8,20 @@ COMMON-SRC=$(wildcard common/*.erl) COMMON-BIN=$(COMMON-SRC:.erl=.beam) -.PHONY: all client server clean +.PHONY: all client server clean clean-client clean-server all: client server -clean: - -$(RM) $(CLIENT-BIN) $(SERVER-BIN) $(COMMON-BIN) +clean: clean-client clean-server + +clean-client: clean-common + -$(RM) $(CLIENT-BIN) + +clean-server: clean-common + -$(RM) $(SERVER-BIN) + +clean-common: + -$(RM) $(COMMON-BIN) client: $(CLIENT-BIN) $(COMMON-BIN) diff --git a/client/Makefile b/client/Makefile new file mode 100644 index 0000000..17cc9a0 --- /dev/null +++ b/client/Makefile @@ -0,0 +1,6 @@ +all: + -$(MAKE) -C.. client + +clean: + -$(MAKE) -C.. clean-client + diff --git a/server/Makefile b/server/Makefile new file mode 100644 index 0000000..a1c185b --- /dev/null +++ b/server/Makefile @@ -0,0 +1,5 @@ +all: + -$(MAKE) -C.. server + +clean: + -$(MAKE) -C.. clean-server -- cgit v1.2.3 From 84937b0728ae3aac1174b32c85df17cf8bf627a5 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 14 Oct 2010 15:22:03 +0200 Subject: added better error messages --- server/dispatcher.erl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/server/dispatcher.erl b/server/dispatcher.erl index 77e4ab9..882bed3 100644 --- a/server/dispatcher.erl +++ b/server/dispatcher.erl @@ -5,12 +5,20 @@ start() -> code:purge(server), code:load_abs("../common/server"), - spawn(media, init, []), + try spawn(media, init, []) of + _ -> + io:format("Media-Backend started!~n") + catch + _: Why -> + io:format("Error starting media backend: ~w! Exiting.~n", [Why]), + exit(1) + end, - case server:start(dis, dispatcher) of + try server:start(dis, dispatcher) of true -> - io:format("Server started... ~n"), - true; + io:format("Server started!~n"), + true + catch _ -> io:format("Error starting server! Exiting.~n"), exit(1) @@ -44,5 +52,5 @@ handle({login, {Node, User, Password}}, Dict) -> handle({'EXIT', _, _}, Dict) -> Dict; -handle(_, Dict) -> - {{error, unknown_command}, Dict}. +handle(Cmd, Dict) -> + {{error, {unknown_command, Cmd}}, Dict}. -- cgit v1.2.3 From 097d7f7dda9c405fb796e3228631a07192f36bd1 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 14 Oct 2010 15:23:22 +0200 Subject: added comments --- server/dispatcher.erl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/dispatcher.erl b/server/dispatcher.erl index 882bed3..e5e0572 100644 --- a/server/dispatcher.erl +++ b/server/dispatcher.erl @@ -2,9 +2,12 @@ -export([start/0, init/0, handle/2]). start() -> + %% load server module from common directory, + %% used form server and client code:purge(server), code:load_abs("../common/server"), + %% spawn media backend in seperat process try spawn(media, init, []) of _ -> io:format("Media-Backend started!~n") @@ -14,6 +17,9 @@ start() -> exit(1) end, + %% start server (registered as dis) + %% server-module will call handle if message arrives and init to + %% initialize the status try server:start(dis, dispatcher) of true -> io:format("Server started!~n"), @@ -53,4 +59,5 @@ handle({'EXIT', _, _}, Dict) -> Dict; handle(Cmd, Dict) -> + %% standard command, to find transmission errors {{error, {unknown_command, Cmd}}, Dict}. -- cgit v1.2.3