This commit is contained in:
Redkale
2020-06-01 21:19:47 +08:00
parent 22fb3e5bef
commit db8c94f433
3 changed files with 11 additions and 0 deletions

View File

@@ -359,6 +359,7 @@ public abstract class NodeServer {
if (groups.isEmpty() && isSNCP() && NodeServer.this.sncpGroup != null) groups.add(NodeServer.this.sncpGroup);
nodeService = Sncp.createLocalService(serverClassLoader, resourceName, WebSocketNodeService.class, application.getResourceFactory(), application.getSncpTransportFactory(), NodeServer.this.sncpAddress, groups, (AnyValue) null);
(isSNCP() ? appResFactory : resourceFactory).register(resourceName, WebSocketNode.class, nodeService);
((WebSocketNodeService) nodeService).setName(resourceName);
}
resourceFactory.inject(nodeService, self);
field.set(src, nodeService);

View File

@@ -41,6 +41,8 @@ public abstract class WebSocketNode {
@Resource(name = Application.RESNAME_SNCP_ADDR)
protected InetSocketAddress localSncpAddress; //为SncpServer的服务address
protected String name;
//如果不是分布式(没有SNCP) 值为null
@RpcRemote
protected WebSocketNode remoteNode;
@@ -128,6 +130,10 @@ public abstract class WebSocketNode {
return changeUserid(olduserid, newuserid, localSncpAddress);
}
public final String getName() {
return name;
}
//--------------------------------------------------------------------------------
/**
* 获取目标地址 <br>

View File

@@ -36,6 +36,10 @@ public class WebSocketNodeService extends WebSocketNode implements Service {
super.destroy(conf);
}
public final void setName(String name) {
this.name = name;
}
@Override
public CompletableFuture<List<String>> getWebSocketAddresses(final @RpcTargetAddress InetSocketAddress targetAddress, final Serializable groupid) {
if (localSncpAddress == null || !localSncpAddress.equals(targetAddress)) return remoteWebSocketAddresses(targetAddress, groupid);