fixed problem with two concurrent players

This commit is contained in:
Jeena Paradies 2011-04-13 16:25:50 +02:00
parent 231bbfdf16
commit f013e75b5c

View file

@ -27,33 +27,13 @@
start(Socket) ->
gen_server:start(?MODULE, [Socket], []).
join_table(Num) ->
case ggs_coordinator:join_table(integer_to_list(Num)) of
{ok, T} ->
io:format("Joining existing table: ~p~n", [T]),
T;
{error, no_such_table} ->
case ggs_coordinator:create_table({force, integer_to_list(Num)}) of
{ok, TBToken} -> ok
end,
case ggs_coordinator:join_table(integer_to_list(Num)) of
{ok, T} -> io:format("Creating new table: ~p~n", [T]),
T;
{error, E} -> erlang:display(E),
join_table(Num+1)
end;
{error, table_full} ->
erlang:display("Table full!"),
join_table(Num+1)
end.
init([Socket]) ->
{ok, Protocol} = ggs_protocol:start_link(),
{ok, Token} = ggs_coordinator:join_lobby(),
erlang:port_connect(Socket, self()),
Table = join_table(1),
Table = ggs_coordinator:join_table(),
State = #state{
token = Token,
socket = Socket,