Class RequestMessage

java.lang.Object
com.iohao.net.framework.protocol.CommonMessage
com.iohao.net.framework.protocol.RequestMessage
All Implemented Interfaces:
FutureMessage, RemoteMessage, Request, UserIdentity
Direct Known Subclasses:
SendMessage

public class RequestMessage extends CommonMessage implements Request
Internal request message used for logic-to-logic server communication via Aeron.

Extends CommonMessage with Request fields including user identity, hop tracking, logic-server binding, and per-request attachment. Provides factory methods for creation and shallow cloning to support request forwarding across logic server boundaries.

Author:
渔民小镇
date:
2025-09-02
  • Constructor Details

    • RequestMessage

      public RequestMessage()
  • Method Details

    • of

      public static RequestMessage of(CmdInfo cmdInfo, byte[] data)
      Create a new RequestMessage with the given command route and payload.
      Parameters:
      cmdInfo - the command route descriptor
      data - the serialized request payload
      Returns:
      a new request message
    • ofClone

      public RequestMessage ofClone()
      Create a shallow clone of this request message, copying all routing and identity fields.

      Useful when forwarding a request to another logic server while preserving the original context.

      Returns:
      a new RequestMessage with the same field values
    • setUserId

      public void setUserId(long userId)
      Description copied from interface: UserIdentity
      Set the user id.
      Specified by:
      setUserId in interface UserIdentity
      Parameters:
      userId - the user id
    • setVerifyIdentity

      public void setVerifyIdentity(boolean verifyIdentity)
      Description copied from interface: UserIdentity
      Set the identity verification flag.
      Specified by:
      setVerifyIdentity in interface UserIdentity
      Parameters:
      verifyIdentity - true if the identity is verified
    • setHopCount

      public void setHopCount(int hopCount)
      Description copied from interface: Request
      Set the number of hops this request has traversed.
      Specified by:
      setHopCount in interface Request
      Parameters:
      hopCount - the hop count to set
    • setBindingLogicServerIds

      public void setBindingLogicServerIds(int[] bindingLogicServerIds)
      Description copied from interface: Request
      Set the IDs of logic servers that this player is bound to.
      Specified by:
      setBindingLogicServerIds in interface Request
      Parameters:
      bindingLogicServerIds - array of bound logic server IDs
    • setAttachment

      public void setAttachment(byte[] attachment)
      Description copied from interface: Request
      Set the per-request attachment data.
      Specified by:
      setAttachment in interface Request
      Parameters:
      attachment - the attachment byte array
    • getUserId

      public long getUserId()
      Description copied from interface: UserIdentity
      Get the user id.
      Specified by:
      getUserId in interface UserIdentity
      Returns:
      the user id
    • isVerifyIdentity

      public boolean isVerifyIdentity()
      Description copied from interface: UserIdentity
      Check whether the user's identity has been verified (authenticated).
      Specified by:
      isVerifyIdentity in interface UserIdentity
      Returns:
      true if the identity is verified
    • getHopCount

      public int getHopCount()
      Description copied from interface: Request
      Get the number of hops this request has traversed across logic servers.
      Specified by:
      getHopCount in interface Request
      Returns:
      the current hop count
    • getBindingLogicServerIds

      public int[] getBindingLogicServerIds()
      Description copied from interface: Request
      The IDs of multiple game logic servers bound to the player
          All requests related to this game logic server will be routed to the bound game logic server for processing.
          Even if multiple game logic servers of the same type are running, requests will still be directed to the originally bound server.
      
      Specified by:
      getBindingLogicServerIds in interface Request
      Returns:
      bindingLogicServerIds
    • getAttachment

      public byte[] getAttachment()
      Description copied from interface: Request
      Extended field. Developers can use this field to extend meta-information for special business needs. The data in this field will be included with every request.
      Specified by:
      getAttachment in interface Request
      Returns:
      AttachmentData