Class ExternalResponseMessage

java.lang.Object
com.iohao.net.framework.protocol.ExternalResponseMessage
All Implemented Interfaces:
CommonResponse, ExternalResponse, FutureMessage

public final class ExternalResponseMessage extends Object implements ExternalResponse
Concrete response message returned from an external (Netty) server to a logic server.

Extends ExternalCommonMessage with error information and implements ExternalResponse to provide payload access and future correlation.

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

    • ExternalResponseMessage

      public ExternalResponseMessage()
  • Method Details

    • setErrorCode

      public void setErrorCode(int errorCode)
      Error code; 0 indicates success, non-zero indicates an error.
      Specified by:
      setErrorCode in interface CommonResponse
      Parameters:
      errorCode - the error code
    • setErrorMessage

      public void setErrorMessage(String errorMessage)
      Human-readable error message; null when the response is successful.
      Specified by:
      setErrorMessage in interface CommonResponse
      Parameters:
      errorMessage - the error message
    • getErrorCode

      public int getErrorCode()
      Error code; 0 indicates success, non-zero indicates an error.
      Specified by:
      getErrorCode in interface CommonResponse
      Returns:
      the error code
    • getErrorMessage

      public String getErrorMessage()
      Human-readable error message; null when the response is successful.
      Specified by:
      getErrorMessage in interface CommonResponse
      Returns:
      the error message, or null on success
    • getPayload

      byte[] getPayload()
      Get the raw binary payload.
      Returns:
      the payload bytes
    • getPayloadAsInt

      default int getPayloadAsInt()
      Deserialize the payload as an int.
      Returns:
      the int value
    • getPayloadAsLong

      default long getPayloadAsLong()
      Deserialize the payload as a long.
      Returns:
      the long value
    • getPayloadAsBool

      default boolean getPayloadAsBool()
      Deserialize the payload as a boolean.
      Returns:
      the boolean value
    • getPayloadAsString

      default String getPayloadAsString()
      Deserialize the payload as a String.
      Returns:
      the string value
    • setPayload

      void setPayload(byte[] payload)
      Set the raw binary payload.
      Parameters:
      payload - the payload bytes
    • setPayload

      default void setPayload(int payload)
      Set the payload from an int value.
      Parameters:
      payload - the int value to serialize
    • setPayload

      default void setPayload(long payload)
      Set the payload from a long value.
      Parameters:
      payload - the long value to serialize
    • setPayload

      default void setPayload(boolean payload)
      Set the payload from a boolean value.
      Parameters:
      payload - the boolean value to serialize
    • setPayload

      default void setPayload(String payload)
      Set the payload from a String value.
      Parameters:
      payload - the string value to serialize
    • getFutureId

      public long getFutureId()
      Correlation id used to match asynchronous request/response pairs.
    • getPayload

      public byte[] getPayload()
      Serialized binary payload of the message.
    • getExternalServerId

      public int getExternalServerId()
      Identifier of the external server that originated or will receive this message.
    • setFutureId

      public void setFutureId(long futureId)
      Correlation id used to match asynchronous request/response pairs.
    • setPayload

      public void setPayload(byte[] payload)
      Serialized binary payload of the message.
    • setExternalServerId

      public void setExternalServerId(int externalServerId)
      Identifier of the external server that originated or will receive this message.