diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2024-03-07 21:58:14 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2024-03-07 21:58:14 +0100 |
commit | d6b2edd8cef2a3ab1bb9488fe7e82920a1333af1 (patch) | |
tree | da99d769f873c269d46c5b59bf38dcd625c9468f | |
parent | 900bda5f4c60898c07e81ff25be57ffc835b68d8 (diff) | |
download | erlang-workshop-d6b2edd8cef2a3ab1bb9488fe7e82920a1333af1.tar.gz erlang-workshop-d6b2edd8cef2a3ab1bb9488fe7e82920a1333af1.tar.bz2 erlang-workshop-d6b2edd8cef2a3ab1bb9488fe7e82920a1333af1.tar.xz erlang-workshop-d6b2edd8cef2a3ab1bb9488fe7e82920a1333af1.zip |
wip
-rw-r--r-- | tictactoe-2/apps/ttt_server/src/game.erl | 12 | ||||
-rw-r--r-- | tictactoe-2/apps/ttt_server/src/ttt_server.erl | 11 |
2 files changed, 18 insertions, 5 deletions
diff --git a/tictactoe-2/apps/ttt_server/src/game.erl b/tictactoe-2/apps/ttt_server/src/game.erl index 8c6550a..1b8aff2 100644 --- a/tictactoe-2/apps/ttt_server/src/game.erl +++ b/tictactoe-2/apps/ttt_server/src/game.erl @@ -2,7 +2,8 @@ -author("trygvis"). -export([ - game_loop/2]). + game_loop/2, + loop/1]). -import(ttt, [empty_board/0]). @@ -31,6 +32,11 @@ loop(State) -> Str = ttt:format(State#state.board), io:format("game ~p: current state:~n~p~n", [Id, Str]), From ! Str, + loop(State); + code_changed -> + io:format("game ~p: code changed~n", [Id]), + ?MODULE:loop(State); + X -> + io:format("unexpected message: ~p~n", [X]), loop(State) - end, - State. + end. diff --git a/tictactoe-2/apps/ttt_server/src/ttt_server.erl b/tictactoe-2/apps/ttt_server/src/ttt_server.erl index c7167fb..a0de947 100644 --- a/tictactoe-2/apps/ttt_server/src/ttt_server.erl +++ b/tictactoe-2/apps/ttt_server/src/ttt_server.erl @@ -52,8 +52,15 @@ loop(State) -> io:format("Exiting~n", []); {stop, Pid} -> Pid ! ok; - recompiled -> - io:format("Reloading~n", []), + code_changed -> + io:format("Code changed~n"), + io:format("Code changed: ~p~n", [State#ttt_state.games]), + orddict:map( + fun(_Id, [G]) -> + io:format("Id=~p, v=~p~n", [_Id, G]), + G#ttt_game.pid ! code_changed + end, + State#ttt_state.games), ?MODULE:loop(State); X -> io:format("unexpected message: ~p~n", [X]), |