Interface IdleHook<IdleEvent>

All Known Subinterfaces:
SocketIdleHook
All Known Implementing Classes:
DefaultSocketIdleHook

public interface IdleHook<IdleEvent>
Heartbeat/idle event callback hook for external user sessions.
Author:
渔民小镇
date:
2023-02-18
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    callback(UserSession userSession, IdleEvent event)
    Heartbeat event callback.
    default void
    Callback before heartbeat response (pong).
  • Method Details

    • callback

      boolean callback(UserSession userSession, IdleEvent event)
      Heartbeat event callback.

      You only need to handle your business logic here, such as notifying other players in the room that the user has gone offline.

      Parameters:
      userSession - target user session
      event - idle event payload from the transport implementation
      Returns:
      true to disconnect the player
    • pongBefore

      default void pongBefore(CommunicationMessage idleMessage)
      Callback before heartbeat response (pong). Developers can add some extra information to the heartbeat message, such as the current time.
      Parameters:
      idleMessage - heartbeat response message that will be sent to the client