Class AbstractCommunicationMessage
java.lang.Object
com.iohao.net.framework.protocol.AbstractCommunicationMessage
- All Implemented Interfaces:
CommonResponse, CommunicationMessage, FutureMessage, RemoteMessage, Request, UserIdentity
- Direct Known Subclasses:
ExternalMessage
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the command code identifying the protocol-level message type.intGet the error code. 0 indicates success; any other value indicates an error.Get the human-readable error message.intgetMsgId()Get the client-assigned message ID for request-response correlation.<T> TgetOther()Get the transient auxiliary object attached to this message.intGet the protocol switch flags controlling codec behavior.voidsetCmdCode(int cmdCode) Set the command code identifying the protocol-level message type.voidsetCmdInfo(CmdInfo cmdInfo) Set the command route from aCmdInfodescriptor.voidsetErrorCode(int errorCode) Set the error code. 0 indicates success; any other value indicates an error.voidsetErrorMessage(String errorMessage) Set the human-readable error message.voidsetMsgId(int msgId) Set the client-assigned message ID.voidsetOutputError(ErrorInformation outputError) Set the error information to be included in the response.voidsetProtocolSwitch(int protocolSwitch) Set the protocol switch flags controlling codec behavior.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 CommunicationMessage
getCacheCondition, getCmdInfo, getCmdMerge, getData, setCacheCondition, setCmdMerge, setDataMethods inherited from interface FutureMessage
getFutureId, setFutureIdMethods inherited from interface RemoteMessage
getExternalServerId, getLogicServerId, getNanoTime, getNetId, getSourceServerId, getTraceId, setExternalServerId, setLogicServerId, setNanoTime, setNetId, setSourceServerId, setTraceIdMethods inherited from interface Request
getAttachment, getBindingLogicServerIds, getHopCount, getStick, setAttachment, setBindingLogicServerIds, setHopCount, setStickMethods inherited from interface UserIdentity
bindingUserId, getUserId, isVerifyIdentity, setUserId, setUserIdentity, setVerifyIdentity, verifyIdentity
-
Constructor Details
-
AbstractCommunicationMessage
public AbstractCommunicationMessage()
-
-
Method Details
-
setOutputError
Set the error information to be included in the response.- Specified by:
setOutputErrorin interfaceRemoteMessage- Parameters:
outputError- the error information
-
setCmdInfo
Set the command route from aCmdInfodescriptor.- Specified by:
setCmdInfoin interfaceRemoteMessage- 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:CommunicationMessageGet the command code identifying the protocol-level message type.- Specified by:
getCmdCodein interfaceCommunicationMessage- Returns:
- the command code
-
setCmdCode
public void setCmdCode(int cmdCode) Description copied from interface:CommunicationMessageSet the command code identifying the protocol-level message type.- Specified by:
setCmdCodein interfaceCommunicationMessage- Parameters:
cmdCode- the command code
-
getProtocolSwitch
public int getProtocolSwitch()Description copied from interface:CommunicationMessageGet the protocol switch flags controlling codec behavior.- Specified by:
getProtocolSwitchin interfaceCommunicationMessage- Returns:
- the protocol switch bitmask
-
setProtocolSwitch
public void setProtocolSwitch(int protocolSwitch) Description copied from interface:CommunicationMessageSet the protocol switch flags controlling codec behavior.- Specified by:
setProtocolSwitchin interfaceCommunicationMessage- Parameters:
protocolSwitch- the protocol switch bitmask
-
getMsgId
public int getMsgId()Description copied from interface:CommunicationMessageGet the client-assigned message ID for request-response correlation.- Specified by:
getMsgIdin interfaceCommunicationMessage- Returns:
- the message ID
-
setMsgId
public void setMsgId(int msgId) Description copied from interface:CommunicationMessageSet the client-assigned message ID.- Specified by:
setMsgIdin interfaceCommunicationMessage- Parameters:
msgId- the message ID
-
getErrorCode
public int getErrorCode()Description copied from interface:CommonResponseGet the error code. 0 indicates success; any other value indicates an error.- Specified by:
getErrorCodein interfaceCommonResponse- Returns:
- the error code
-
setErrorCode
public void setErrorCode(int errorCode) Description copied from interface:CommonResponseSet the error code. 0 indicates success; any other value indicates an error.- Specified by:
setErrorCodein interfaceCommonResponse- Parameters:
errorCode- the error code
-
getErrorMessage
Description copied from interface:CommonResponseGet the human-readable error message.- Specified by:
getErrorMessagein interfaceCommonResponse- Returns:
- the error message, or
nullon success
-
setErrorMessage
Description copied from interface:CommonResponseSet the human-readable error message.- Specified by:
setErrorMessagein interfaceCommonResponse- Parameters:
errorMessage- the error message
-