Class DefaultCommunicationAggregation
java.lang.Object
com.iohao.net.server.DefaultCommunicationAggregation
- All Implemented Interfaces:
BroadcastCommunication, CommunicationAggregation, EventBusMessageCommunication, ExternalCollectCommunication, ExternalCommunication, LogicCollectCommunication, LogicCommunication, PublisherCommunication, NetServerSettingAware
public class DefaultCommunicationAggregation
extends Object
implements CommunicationAggregation, NetServerSettingAware
Default communication aggregation implementation for routing, broadcasting, and RPC-like calls.
- Since:
- 25.1
- Author:
- 渔民小镇
- date:
- 2025-09-07
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConnectionManagerprotected ExternalServerLoadBalancedprotected FindServerprotected FutureManagerprotected Publisher -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSynchronously bind a user session to a specific logic server.Asynchronously bind a user session to a specific logic server.voidbroadcast(BroadcastMulticastMessage message) Broadcast a message to multiple recipients via multicast.voidbroadcast(BroadcastUserListMessage message) Broadcast a message to a specific list of users.voidbroadcast(BroadcastUserMessage message) Broadcast a message to a single user (unicast).call(RequestMessage message) Call another logic server and block until a response is received.callCollect(RequestMessage message) Synchronously call all matching logic servers and collect their responses.Synchronously call all external servers and collect their responses.Asynchronously call all external servers and collect their responses.callCollectFuture(RequestMessage message) Asynchronously call all matching logic servers and collect their responses.callExternal(ExternalRequestMessage message) Send a request to an external server and block until a response is received.callExternalFuture(ExternalRequestMessage message) Send a request to an external server asynchronously.callFuture(RequestMessage message) Call another logic server asynchronously and return a future for the response.voidfireRemote(EventBusMessage message) Fire an event bus message to remote logic servers.protected CompletableFuture<Response> ofErrorFuture(ErrorInformation errorInformation) voidpublishMessage(int serverId, Object message) Publish a message to a server identified by its server ID.voidpublishMessage(String name, Object message) Publish a message to a server identified by its logical name.voidpublishMessageByNetId(int netId, Object message) Publish a message to a server identified by its net ID.voidsend(SendMessage message) Send a message to another logic server without expecting a response (fire-and-forget).voidsetNetServerSetting(NetServerSetting setting) Injects the runtime setting.voidwriteMessage(UserResponseMessage message) Write a response message directly to a user session on the external server.
-
Field Details
-
connectionManager
-
externalServerLoadBalanced
-
futureManager
-
publisher
-
findServer
-
-
Constructor Details
-
DefaultCommunicationAggregation
public DefaultCommunicationAggregation()
-
-
Method Details
-
setNetServerSetting
Description copied from interface:NetServerSettingAwareInjects the runtime setting.- Specified by:
setNetServerSettingin interfaceNetServerSettingAware- Parameters:
setting- runtime setting
-
publishMessageByNetId
Description copied from interface:PublisherCommunicationPublish a message to a server identified by its net ID.- Specified by:
publishMessageByNetIdin interfacePublisherCommunication- Parameters:
netId- the net ID of the target servermessage- the message to publish
-
publishMessage
Description copied from interface:PublisherCommunicationPublish a message to a server identified by its server ID.- Specified by:
publishMessagein interfacePublisherCommunication- Parameters:
serverId- the server ID of the target servermessage- the message to publish
-
publishMessage
Description copied from interface:PublisherCommunicationPublish a message to a server identified by its logical name.- Specified by:
publishMessagein interfacePublisherCommunication- Parameters:
name- the logical name of the target servermessage- the message to publish
-
writeMessage
Description copied from interface:ExternalCollectCommunicationWrite a response message directly to a user session on the external server.- Specified by:
writeMessagein interfaceExternalCollectCommunication- Parameters:
message- the user response message to deliver
-
broadcast
Description copied from interface:BroadcastCommunicationBroadcast a message to a single user (unicast).- Specified by:
broadcastin interfaceBroadcastCommunication- Parameters:
message- the unicast broadcast message
-
broadcast
Description copied from interface:BroadcastCommunicationBroadcast a message to a specific list of users.- Specified by:
broadcastin interfaceBroadcastCommunication- Parameters:
message- the user-list broadcast message
-
broadcast
Description copied from interface:BroadcastCommunicationBroadcast a message to multiple recipients via multicast.- Specified by:
broadcastin interfaceBroadcastCommunication- Parameters:
message- the multicast broadcast message
-
callExternal
Description copied from interface:ExternalCommunicationSend a request to an external server and block until a response is received.- Specified by:
callExternalin interfaceExternalCommunication- Parameters:
message- the external request message- Returns:
- the external response
-
callExternalFuture
Description copied from interface:ExternalCommunicationSend a request to an external server asynchronously.- Specified by:
callExternalFuturein interfaceExternalCommunication- Parameters:
message- the external request message- Returns:
- a
CompletableFuturethat completes with the external response
-
callCollectExternalFuture
public CompletableFuture<ResponseCollectExternal> callCollectExternalFuture(ExternalRequestMessage message) Description copied from interface:ExternalCollectCommunicationAsynchronously call all external servers and collect their responses.- Specified by:
callCollectExternalFuturein interfaceExternalCollectCommunication- Parameters:
message- the external request message to broadcast- Returns:
- a future that completes with the aggregated response from all external servers
-
callCollectExternal
Description copied from interface:ExternalCollectCommunicationSynchronously call all external servers and collect their responses.- Specified by:
callCollectExternalin interfaceExternalCollectCommunication- Parameters:
message- the external request message to broadcast- Returns:
- the aggregated response from all external servers
-
bindingLogicServerFuture
public CompletableFuture<CommonResponse> bindingLogicServerFuture(BindingLogicServerMessage message) Description copied from interface:ExternalCollectCommunicationAsynchronously bind a user session to a specific logic server.- Specified by:
bindingLogicServerFuturein interfaceExternalCollectCommunication- Parameters:
message- the binding request message- Returns:
- a future that completes with the common response
-
bindingLogicServer
Description copied from interface:ExternalCollectCommunicationSynchronously bind a user session to a specific logic server.- Specified by:
bindingLogicServerin interfaceExternalCollectCommunication- Parameters:
message- the binding request message- Returns:
- the common response indicating success or failure
-
callFuture
Description copied from interface:LogicCommunicationCall another logic server asynchronously and return a future for the response.- Specified by:
callFuturein interfaceLogicCommunication- Parameters:
message- the request message- Returns:
- a
CompletableFuturethat completes with the response
-
call
Description copied from interface:LogicCommunicationCall another logic server and block until a response is received.- Specified by:
callin interfaceLogicCommunication- Parameters:
message- the request message- Returns:
- the response from the target logic server
-
send
Description copied from interface:LogicCommunicationSend a message to another logic server without expecting a response (fire-and-forget).- Specified by:
sendin interfaceLogicCommunication- Parameters:
message- the send message
-
callCollectFuture
Description copied from interface:LogicCollectCommunicationAsynchronously call all matching logic servers and collect their responses.- Specified by:
callCollectFuturein interfaceLogicCollectCommunication- Parameters:
message- the request message to broadcast- Returns:
- a future that completes with the aggregated response from all logic servers
-
callCollect
Description copied from interface:LogicCollectCommunicationSynchronously call all matching logic servers and collect their responses.- Specified by:
callCollectin interfaceLogicCollectCommunication- Parameters:
message- the request message to broadcast- Returns:
- the aggregated response from all logic servers
-
ofErrorFuture
-
fireRemote
Description copied from interface:EventBusMessageCommunicationFire an event bus message to remote logic servers.- Specified by:
fireRemotein interfaceEventBusMessageCommunication- Parameters:
message- the event bus message to dispatch remotely
-