Interface UserSession

All Superinterfaces:
AttrOptionDynamic
All Known Implementing Classes:
SocketUserSession

public interface UserSession extends AttrOptionDynamic
External user session abstraction for one connected client.
Author:
渔民小镇
See Also:
date:
2023-02-18
  • Method Details

    • isActive

      boolean isActive()
      Check whether the session is active.
      Returns:
      true if the session is active
    • setExternalJoin

      void setExternalJoin(ExternalJoinEnum externalJoin)
      Set the transport type used by this session.
      Parameters:
      externalJoin - external transport type
    • setUserId

      void setUserId(long userId)
      Sets the ID of the current user (player).
      Parameters:
      userId - business user id
    • getUserId

      long getUserId()
      Gets the ID of the current user (player).
      Returns:
      current business user id
    • isVerifyIdentity

      boolean isVerifyIdentity()
      Checks if the identity has been verified.
      Returns:
      true if logged in
    • getState

      UserSessionState getState()
      Get the current session state.
      Returns:
      session state
    • getUserChannelId

      long getUserChannelId()
      Gets the UserChannelId of the current user (player).
      Returns:
      user channel id
    • employ

      void employ(CommunicationMessage message)
      Adds user info to request. Developers can extend data via HeadMetadata.setAttachmentData(byte[]), which will be forwarded to the logic server.
      Parameters:
      message - outbound message to enrich with session identity/attachment data
    • writeAndFlush

      <T> T writeAndFlush(Object message)
      Write a message to the client and flush immediately.
      Parameters:
      message - message object
      Returns:
      transport-specific future or write result
    • getIp

      String getIp()
      Get the client IP address.
      Returns:
      player IP
    • setAttachment

      void setAttachment(byte[] attachment)
      Set the attachment bytes stored on the session.
      Parameters:
      attachment - attachment bytes
    • setBindingLogicServerIds

      void setBindingLogicServerIds(int[] bindingLogicServerIds)
      Set logic server bindings associated with this session.
      Parameters:
      bindingLogicServerIds - bound logic server ids
    • getBindingLogicServerIds

      int[] getBindingLogicServerIds()
      Get logic server bindings associated with this session.
      Returns:
      bound logic server ids
    • ofMessage

      default CommunicationMessage ofMessage(CmdInfo cmdInfo)
      Create and populate a communication message for the given route.
      Parameters:
      cmdInfo - route metadata
      Returns:
      initialized communication message with session identity data