Added some more ggsvm_e functionality and also a chat client
This commit is contained in:
parent
883cf9e9d7
commit
67567fe263
15 changed files with 1058 additions and 45 deletions
|
@ -26,10 +26,12 @@ start_link(Socket) ->
|
|||
TableStatus = ggs_coordinator:join_table(1337),
|
||||
case TableStatus of
|
||||
{ok, Table} ->
|
||||
notify(self(), self(), Token),
|
||||
loop(#pl_state{socket = Socket, token = Token, table = Table});
|
||||
{error, no_such_table} ->
|
||||
ggs_coordinator:create_table({force, 1337}),
|
||||
{ok, Table} = ggs_coordinator:join_table(1337),
|
||||
notify(self(), self(), Token),
|
||||
loop(#pl_state{socket = Socket, token = Token, table = Table})
|
||||
end.
|
||||
|
||||
|
@ -57,10 +59,25 @@ stop(_Player,_Table) ->
|
|||
loop(#pl_state{token = Token, socket = Socket, table = Table} = State) ->
|
||||
receive
|
||||
{tcp, Socket, Data} -> % Just echo for now..
|
||||
io:format("Notifying table..~n"),
|
||||
ggs_table:notify_game(Table, Token, Data),
|
||||
io:format("Parsing via protocol module..~n"),
|
||||
Parsed = ggs_protocol:parse(Data),
|
||||
self() ! Parsed,
|
||||
loop(State);
|
||||
{notify, From, Message} ->
|
||||
gen_tcp:send(Socket, Message),
|
||||
loop(State)
|
||||
loop(State);
|
||||
% Below are messages generated by the parser
|
||||
{game_cmd,Cmd, Headers, Data} ->
|
||||
ggs_table:notify(Table, self(), {game, Cmd, Data}),
|
||||
loop(State);
|
||||
{srv_cmd,"define", Headers, Data} ->
|
||||
ggs_table:notify(Table, self(), {server, define, Data}),
|
||||
loop(State);
|
||||
{tcp_closed, _Socket} ->
|
||||
io:format("Client disconnected, but THIS IS NOT SUPPORTED YET!~n"),
|
||||
loop(State);
|
||||
Other ->
|
||||
io:format("Got UNKNOWN message: "),
|
||||
erlang:display(Other),
|
||||
io:format("~n")
|
||||
end.
|
||||
|
|
Reference in a new issue