Commit a7ed90d5cdb20f710257e0784c17dd4e70bcd3c5

Authored by dg
1 parent 94badf6a

notify of connections


git-svn-id: http://svn.net-core.org/repos/t-engine4@2892 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -432,6 +432,14 @@ function _M:eventChat(e)
432 432 self.chat:event(e)
433 433 end
434 434
  435 +function _M:eventConnected(e)
  436 + if game and type(game) == "table" and game.log then game.log("#YELLOW#Connection to online server established.") end
  437 +end
  438 +
  439 +function _M:eventDisconnected(e)
  440 + if game and type(game) == "table" and game.log then game.log("#YELLOW#Connection to online server lost, trying to reconnect.") end
  441 +end
  442 +
435 443 --- Got an event from the profile thread
436 444 function _M:handleEvent(e)
437 445 e = e:unserialize()
... ...
... ... @@ -36,6 +36,7 @@ function _M:connected()
36 36 print("[PROFILE] Thread connected to te4.org")
37 37 self:login()
38 38 self.chat:reconnect()
  39 + cprofile.pushEvent("e='Connected'")
39 40 return true
40 41 end
41 42
... ... @@ -55,6 +56,12 @@ function _M:write(str, ...)
55 56 end
56 57
57 58 function _M:disconnect()
  59 + cprofile.pushEvent("e='Disconnected'")
  60 + if self.psock then
  61 + self.psock:close()
  62 + self.psock = nil
  63 + end
  64 + self.sock:close()
58 65 self.sock = nil
59 66 self.auth = nil
60 67 core.game.sleep(5000) -- Wait 5 secs
... ... @@ -120,7 +127,6 @@ function _M:pread(ncode)
120 127 end
121 128
122 129 function _M:login()
123   -print("profile login", self.sock , self.auth , self.user_login , self.user_pass)
124 130 if self.sock and not self.auth and self.user_login and self.user_pass then
125 131 self:command("AUTH", self.user_login)
126 132 self:read("200")
... ... @@ -194,7 +200,6 @@ function _M:run()
194 200 end
195 201
196 202 function _M:handleOrder(o)
197   - print("==== profile order ====", o)
198 203 o = o:unserialize()
199 204 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
200 205 if self["order"..o.o] then self["order"..o.o](self, o) end
... ...