DisconnectProxy.lua 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. local RemoteProxy = requireProxy( "remote/RemoteProxy" )
  2. local DisconnectProxy = class( "DisconnectProxy", RemoteProxy )
  3. DisconnectProxy.NAME = global.ProxyTable.Disconnect
  4. function DisconnectProxy:ctor()
  5. DisconnectProxy.super.ctor( self )
  6. self._disconnect = false
  7. end
  8. function DisconnectProxy:IsDisconnect()
  9. return self._disconnect
  10. end
  11. function DisconnectProxy:SetDisconnect( value )
  12. self._disconnect = value
  13. end
  14. function DisconnectProxy:handle_MSG_SC_NETWORK_DISCONNECTED( msg )
  15. self:SetDisconnect( true )
  16. global.Facade:sendNotification( global.NoticeTable.Disconnect )
  17. SLBridge:onLUAEvent(LUA_EVENT_DISCONNECT)
  18. local ServerTimeProxy = global.Facade:retrieveProxy(global.ProxyTable.ServerTimeProxy)
  19. ServerTimeProxy:CloseCheckDisconnectTimer()
  20. end
  21. function DisconnectProxy:handle_MSG_SC_NETWORK_ILLEGAL_MSG( msg )
  22. self:SetDisconnect( true )
  23. local header = msg:GetHeader()
  24. global.Facade:sendNotification( global.NoticeTable.IllegalMsg, header.param1 )
  25. end
  26. function DisconnectProxy:handle_MSG_SC_NETWORK_OTHERPLACE_LOGIN( msg )
  27. self:SetDisconnect( true )
  28. global.Facade:sendNotification( global.NoticeTable.OtherClientLogin )
  29. end
  30. function DisconnectProxy:RegisterMsgHandler()
  31. DisconnectProxy.super.RegisterMsgHandler(self)
  32. local msgType = global.MsgType
  33. LuaRegisterMsgHandler( msgType.MSG_SC_NETWORK_DISCONNECTED, handler( self, self.handle_MSG_SC_NETWORK_DISCONNECTED ) ) -- 断线
  34. LuaRegisterMsgHandler( msgType.MSG_SC_NETWORK_ILLEGAL_MSG, handler( self, self.handle_MSG_SC_NETWORK_ILLEGAL_MSG ) ) -- 非法消息
  35. LuaRegisterMsgHandler( msgType.MSG_SC_NETWORK_OTHERPLACE_LOGIN, handler( self, self.handle_MSG_SC_NETWORK_OTHERPLACE_LOGIN ) ) -- other client login
  36. end
  37. return DisconnectProxy