Class DefaultCommunication

java.lang.Object
com.iohao.net.framework.communication.DefaultCommunication
All Implemented Interfaces:
BroadcastMulticastCommunicationDecorator, BroadcastUserCommunicationDecorator, BroadcastUserListCommunicationDecorator, CommonDecorator, Communication, ExternalCommunicationDecorator, LogicCallCollectCommunicationDecorator, LogicCallCommunicationDecorator, LogicCommunicationDecorator, LogicSendCommunicationDecorator

public class DefaultCommunication extends Object implements Communication
Default implementation of Communication that delegates to the global CommunicationAggregation.

Creates protocol messages (ExternalRequestMessage and RequestMessage) by populating them with trace IDs, network IDs, and source server metadata from the current FlowContext.

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

    • DefaultCommunication

      public DefaultCommunication()
  • Method Details

    • ofExternalRequestMessage

      public ExternalRequestMessage ofExternalRequestMessage(int templateId, byte[] payload)
      Create an ExternalRequestMessage for communicating with external servers.

      Populates the message with the given template ID, payload, current trace ID, and the global network ID from CoreGlobalConfig.

      Specified by:
      ofExternalRequestMessage in interface ExternalCommunicationDecorator
      Parameters:
      templateId - the external request template identifier
      payload - the serialized request payload (may be null)
      Returns:
      a fully populated external request message
    • ofRequestMessage

      public RequestMessage ofRequestMessage(CmdInfo cmdInfo, byte[] dataBytes)
      Create a RequestMessage for inter-logic-server communication.

      Derives the current FlowContext via FlowContextKeys, copies routing metadata from the original request, and sets the network ID and source server ID.

      Specified by:
      ofRequestMessage in interface LogicCommunicationDecorator
      Parameters:
      cmdInfo - the command routing information (cmd + subCmd)
      dataBytes - the serialized request data
      Returns:
      a fully populated request message ready for dispatch