diff --git a/game/engines/default/engine/PlayerProfile.lua b/game/engines/default/engine/PlayerProfile.lua index 486a9692c2b0b7d4956b2becb21dd1369d2832a6..7d465ed410702d164883405f8b78fcfcad493f8a 100644 --- a/game/engines/default/engine/PlayerProfile.lua +++ b/game/engines/default/engine/PlayerProfile.lua @@ -432,6 +432,14 @@ function _M:eventChat(e) self.chat:event(e) end +function _M:eventConnected(e) + if game and type(game) == "table" and game.log then game.log("#YELLOW#Connection to online server established.") end +end + +function _M:eventDisconnected(e) + if game and type(game) == "table" and game.log then game.log("#YELLOW#Connection to online server lost, trying to reconnect.") end +end + --- Got an event from the profile thread function _M:handleEvent(e) e = e:unserialize() diff --git a/game/profile-thread/Client.lua b/game/profile-thread/Client.lua index 8b9f60b0d6537e5d73fd76c49e724fa332c6f06d..f773c7aa41cb9028918ea0aff7cd65b088903845 100644 --- a/game/profile-thread/Client.lua +++ b/game/profile-thread/Client.lua @@ -36,6 +36,7 @@ function _M:connected() print("[PROFILE] Thread connected to te4.org") self:login() self.chat:reconnect() + cprofile.pushEvent("e='Connected'") return true end @@ -55,6 +56,12 @@ function _M:write(str, ...) end function _M:disconnect() + cprofile.pushEvent("e='Disconnected'") + if self.psock then + self.psock:close() + self.psock = nil + end + self.sock:close() self.sock = nil self.auth = nil core.game.sleep(5000) -- Wait 5 secs @@ -120,7 +127,6 @@ function _M:pread(ncode) end function _M:login() -print("profile login", self.sock , self.auth , self.user_login , self.user_pass) if self.sock and not self.auth and self.user_login and self.user_pass then self:command("AUTH", self.user_login) self:read("200") @@ -194,7 +200,6 @@ function _M:run() end function _M:handleOrder(o) - print("==== profile order ====", o) o = o:unserialize() if not self.sock and o.o ~= "Login" and o.o ~= "CurrentCharacter" and o.o ~= "CheckModuleHash" then return end -- Dont do stuff without a connection, unless we try to auth if self["order"..o.o] then self["order"..o.o](self, o) end