So here's what is happening:
If I run the code and the packet reception is only in 'hub.lua', then everything is working just fine, but if I add the packet reception code to the 'chat.lua' (which is first called in 'Stage.lua') for example, the game freezes with no crash reports. The same happens if I remove packet reception code from both 'chat' and 'hub' and place it in the 'main.lua', which lead me to a conclusion that the problem is caused by call of connection:receive.
The problem is definitely is not on the server side as I have checked all packets that are being sent to the client.
Here's the code:
"hub.lua" (somewhere in the 'hub.update' function) :
Code: Select all
if _t > _updaterate then
repeat
_data = _udp:receive() --data receive problem. Possible leak
if _data ~= nil then
_currentCmd, _currentAnws = _data:match("^(%S*) (%S*)")
_data = nil
end
until not _data
_t = _t - _updaterate
end
if _currentCmd == "anwser" then
_status = _currentAnws
_currentCmd = nil
if tonumber(_status) == 1 then
gotoRoom("Stage")
elseif tonumber(_status) == 0 then
_udp:close()
_udp = Socket.udp()
connectBtn:setData(connectBtn, 0)
_status = "No slots available for this address or a connection with your address was not closed" --change to receive error
end
end
Code: Select all
function love.update(dt)
_t = _t + dt
if _udp ~= nil then
if _t > _updaterate then
repeat
local _data, msg = _udp:receive() --data receive problem. Possible leak
if _data then
_currentCmd, _currentAnws = _data:match("^(%S*) (%S*)")
_data = nil
end
until not _data
_t = _t - _updaterate
end
end
camera:update(dt)
uMouse:update(dt)
if current_room then
current_room:update(dt)
end
end