A Player Log Out Event?

Discussion in 'Plugin Development' started by Gater12, Mar 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Gater12

    So I stumbled accross an obstacle while programming: Is there of any way detecting the reason of disconnection? Like a normal disconnection, timed-out, crashing, etc. is there of any way of detecting that?
     
  2. Offline

    xTigerRebornx

    Gater12 I've found something that might be of interest, in the ProtocolLib API, there is a Disconnect Packet (I believe it is a packet), could try and use ProtocolLib to work with it
     
    Gater12 likes this.
  3. Offline

    Garris0n

    You could also probably find the time since their last keepalive packet somewhere and check if it's over the limit to disconnect them server-side. That way you could check if the client disconnected or the server disconnected. As far as I know you can't detect if they time out vs if they crash, though. Both have the same result on the server, which is the client won't respond to keepalive packets, so they get disconnected by the server.
     
    Gater12 likes this.
  4. Offline

    SquidFruit

    Isn't there just a PlayerQuitEvent
     
  5. Offline

    ImPhantom

    SquidFruit
    Yes. But it isn't possible to get the cause of the disconnection.
     
  6. Offline

    RawCode

    as already stated - Disconnect packet will do job, server do know reason by it's own
    Code:
        public void channelInactive(ChannelHandlerContext channelhandlercontext) {
            this.a((IChatBaseComponent) (new ChatMessage("disconnect.endOfStream", new Object[0])));
        }
    
        public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
            this.a((IChatBaseComponent) (new ChatMessage("disconnect.genericReason", new Object[] { "Internal Exception: " + throwable})));
    
    you can hook to chat messages
     
    Gater12 and Garris0n like this.
  7. Offline

    Garris0n

    RawCode Huh, if it uses those to disconnect a player I wonder if it's possible to use the 1.7 tooltips on the message. Something tells me it won't work, but I'll have to try that out later.
     
  8. Offline

    RawCode

    Internal Exception: java.io.IOException: An existing connection was forcibly closed by the remote host
    vs
    Disconnected

    changing stuff inside lang file does not work (or i did something wrong)

    it will be extra easy to just add log4j console handler and catch messages like above to track reason of disconnection, it wont be difficult to track source of messages
     
Thread Status:
Not open for further replies.

Share This Page