I am writing a game server with Chicagoboss and mnesia. I create two processes in another module where i created in lib folder, messaging each other every 15ms and sending match state to match watchers.
-module(engine).
-export([ spawn/1, receiver/1, sender/0 ]).
spawn(MatchId)-> io:format("spwner activated"),
Pid2 = spawn(engine, sender, []),
Pid3 = spawn(engine, receiver, [Pid2]),
Pid2 ! {Pid3, MatchId},
receiver(Pid2).
receiver(Pid2) ->
receive
{Pid2, MatchId} ->
io:format("Process Sender: ~p~n",[Pid2]),
Pid2 ! {self(), MatchId}
end,
receiver(Pid2).
sender() ->
receive
{From, MatchId} ->
%From ! {self(), Msg},
io:format("Process Receiver: ~p and matchid:~p~n",[From,MatchId]),
%SEND MATCH DATA
case boss_db:find(jamir_match_data,[{match_id,'equals',MatchId}]) of
[] -> [];
EXTMATCH -> [{MatchDatabase,SqlMatchId,NewMatchId,Watchers,PlayersCount,ArenaData,PlayerData,BulletData,BombData,RobotData,VehicleData,CreatureData,GemData,ResponseData,Process}] = EXTMATCH,
[WATCHERS,DATA] = prepareData(EXTMATCH),
PACK = jsx:encode(DATA),
lists:map(fun(EACHWATCHERWS) ->
EACHWATCHERWS ! {text,<< "e&" , PACK/binary , "&1&1&1&1&1&1&1" >>}
end, WATCHERS),
NEWRESPONSELIST = [0,0,0,0,0,0,0,0],
[UpdateMatch] = EXTMATCH,
UpdatedRecord = UpdateMatch:set([{response_data, NEWRESPONSELIST}]),
UpdatedRecord2 = UpdatedRecord:set([{bullet_data, []}]),
UpdatedRecord2:save()
end,
%LOOP
erlang:send_after(15, From , {self(), MatchId});
stop ->
true
end,
sender().
Two processes working fine but after sending starts, handle_info in websocket module stopped getting messages from client. It can be a simple question but i am really stucked at this point and any help would be great.