Class ExternalResponseMessage
java.lang.Object
com.iohao.net.framework.protocol.ExternalResponseMessage
- All Implemented Interfaces:
CommonResponse, ExternalResponse, FutureMessage
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintError code; 0 indicates success, non-zero indicates an error.Human-readable error message;nullwhen the response is successful.intIdentifier of the external server that originated or will receive this message.longCorrelation id used to match asynchronous request/response pairs.byte[]Serialized binary payload of the message.byte[]Get the raw binary payload.default booleanDeserialize the payload as aboolean.default intDeserialize the payload as anint.default longDeserialize the payload as along.default StringDeserialize the payload as aString.voidsetErrorCode(int errorCode) Error code; 0 indicates success, non-zero indicates an error.voidsetErrorMessage(String errorMessage) Human-readable error message;nullwhen the response is successful.voidsetExternalServerId(int externalServerId) Identifier of the external server that originated or will receive this message.voidsetFutureId(long futureId) Correlation id used to match asynchronous request/response pairs.default voidsetPayload(boolean payload) Set the payload from abooleanvalue.voidsetPayload(byte[] payload) Serialized binary payload of the message.voidsetPayload(byte[] payload) Set the raw binary payload.default voidsetPayload(int payload) Set the payload from anintvalue.default voidsetPayload(long payload) Set the payload from alongvalue.default voidsetPayload(String payload) Set the payload from aStringvalue.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CommonResponse
hasError, isSuccess, setErrorMethods inherited from interface ExternalResponse
getExternalServerIdMethods inherited from interface FutureMessage
getFutureId, setFutureId
-
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:
setErrorCodein interfaceCommonResponse- Parameters:
errorCode- the error code
-
setErrorMessage
Human-readable error message;nullwhen the response is successful.- Specified by:
setErrorMessagein interfaceCommonResponse- Parameters:
errorMessage- the error message
-
getErrorCode
public int getErrorCode()Error code; 0 indicates success, non-zero indicates an error.- Specified by:
getErrorCodein interfaceCommonResponse- Returns:
- the error code
-
getErrorMessage
Human-readable error message;nullwhen the response is successful.- Specified by:
getErrorMessagein interfaceCommonResponse- Returns:
- the error message, or
nullon success
-
getPayload
byte[] getPayload()Get the raw binary payload.- Returns:
- the payload bytes
-
getPayloadAsInt
default int getPayloadAsInt()Deserialize the payload as anint.- Returns:
- the int value
-
getPayloadAsLong
default long getPayloadAsLong()Deserialize the payload as along.- Returns:
- the long value
-
getPayloadAsBool
default boolean getPayloadAsBool()Deserialize the payload as aboolean.- Returns:
- the boolean value
-
getPayloadAsString
-
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 anintvalue.- Parameters:
payload- the int value to serialize
-
setPayload
default void setPayload(long payload) Set the payload from alongvalue.- Parameters:
payload- the long value to serialize
-
setPayload
default void setPayload(boolean payload) Set the payload from abooleanvalue.- Parameters:
payload- the boolean value to serialize
-
setPayload
-
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.
-