ToontownClient: Handle CLIENT_HEARTBEAT, CLIENT_DISCONNECT

This commit is contained in:
John Cote 2024-09-07 19:40:39 -04:00
parent 4e43ff6f9e
commit ce93dd70e5
2 changed files with 20 additions and 1 deletions

8
otpgo/lua/MsgTypes.lua Normal file
View File

@ -0,0 +1,8 @@
CLIENT_DISCONNECT = 37
CLIENT_HEARTBEAT = 52
-- new toontown specific login message, adds last logged in, and if child account has parent acount
CLIENT_LOGIN_TOONTOWN = 125
CLIENT_DISCONNECT_GENERIC = 1

View File

@ -1,6 +1,17 @@
package.path = package.path .. ";lua/?.lua"
-- Load message types
dofile("lua/MsgTypes.lua")
function receiveDatagram(client, dgi)
-- Client received datagrams
msgType = dgi:readUint16()
print(msgType)
if msgType == CLIENT_HEARTBEAT then
client:handleHeartbeat()
elseif msgType == CLIENT_DISCONNECT then
client:handleDisconnect()
else
client:sendDisconnect(CLIENT_DISCONNECT_GENERIC, string.format("Unknown message type: %d", msgType), true)
end
end