Class AbstractCommunicationMessage

java.lang.Object
com.iohao.net.framework.protocol.AbstractCommunicationMessage
All Implemented Interfaces:
CommonResponse, CommunicationMessage, FutureMessage, RemoteMessage, Request, UserIdentity
Direct Known Subclasses:
ExternalMessage

public abstract class AbstractCommunicationMessage extends Object implements CommunicationMessage
Abstract base implementation of CommunicationMessage for external protocol codecs.

Stores all routing, identity, and metadata fields as transient members annotated with @Ignore so they are excluded from protobuf serialization. Subclasses (e.g., WebSocket and TCP codec messages) only serialize their protocol-specific wire fields while inheriting the full CommunicationMessage contract. Provides no-op defaults for fields not used in every codec variant (cmdCode, protocolSwitch, msgId, error fields).

Since:
25.1
Author:
渔民小镇
date:
2025-09-24
  • Constructor Details

    • AbstractCommunicationMessage

      public AbstractCommunicationMessage()
  • Method Details

    • setOutputError

      public void setOutputError(ErrorInformation outputError)
      Set the error information to be included in the response.
      Specified by:
      setOutputError in interface RemoteMessage
      Parameters:
      outputError - the error information
    • setCmdInfo

      public void setCmdInfo(CmdInfo cmdInfo)
      Set the command route from a CmdInfo descriptor.
      Specified by:
      setCmdInfo in interface RemoteMessage
      Parameters:
      cmdInfo - the command info containing the merged route key
    • getOther

      public <T> T getOther()
      Get the transient auxiliary object attached to this message.
      Type Parameters:
      T - the expected type
      Returns:
      the auxiliary object, cast to T
    • getCmdCode

      public int getCmdCode()
      Description copied from interface: CommunicationMessage
      Get the command code identifying the protocol-level message type.
      Specified by:
      getCmdCode in interface CommunicationMessage
      Returns:
      the command code
    • setCmdCode

      public void setCmdCode(int cmdCode)
      Description copied from interface: CommunicationMessage
      Set the command code identifying the protocol-level message type.
      Specified by:
      setCmdCode in interface CommunicationMessage
      Parameters:
      cmdCode - the command code
    • getProtocolSwitch

      public int getProtocolSwitch()
      Description copied from interface: CommunicationMessage
      Get the protocol switch flags controlling codec behavior.
      Specified by:
      getProtocolSwitch in interface CommunicationMessage
      Returns:
      the protocol switch bitmask
    • setProtocolSwitch

      public void setProtocolSwitch(int protocolSwitch)
      Description copied from interface: CommunicationMessage
      Set the protocol switch flags controlling codec behavior.
      Specified by:
      setProtocolSwitch in interface CommunicationMessage
      Parameters:
      protocolSwitch - the protocol switch bitmask
    • getMsgId

      public int getMsgId()
      Description copied from interface: CommunicationMessage
      Get the client-assigned message ID for request-response correlation.
      Specified by:
      getMsgId in interface CommunicationMessage
      Returns:
      the message ID
    • setMsgId

      public void setMsgId(int msgId)
      Description copied from interface: CommunicationMessage
      Set the client-assigned message ID.
      Specified by:
      setMsgId in interface CommunicationMessage
      Parameters:
      msgId - the message ID
    • getErrorCode

      public int getErrorCode()
      Description copied from interface: CommonResponse
      Get the error code. 0 indicates success; any other value indicates an error.
      Specified by:
      getErrorCode in interface CommonResponse
      Returns:
      the error code
    • setErrorCode

      public void setErrorCode(int errorCode)
      Description copied from interface: CommonResponse
      Set the error code. 0 indicates success; any other value indicates an error.
      Specified by:
      setErrorCode in interface CommonResponse
      Parameters:
      errorCode - the error code
    • getErrorMessage

      public String getErrorMessage()
      Description copied from interface: CommonResponse
      Get the human-readable error message.
      Specified by:
      getErrorMessage in interface CommonResponse
      Returns:
      the error message, or null on success
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Description copied from interface: CommonResponse
      Set the human-readable error message.
      Specified by:
      setErrorMessage in interface CommonResponse
      Parameters:
      errorMessage - the error message