This commit is contained in:
Redkale
2020-06-10 23:06:20 +08:00
parent 1a1dd44f34
commit 7185191d91
2 changed files with 5 additions and 7 deletions

View File

@@ -159,8 +159,11 @@ public abstract class MessageAgent {
//格式: sncp.req.user
public final String generateSncpReqTopic(Service service) {
if (service instanceof WebSocketNode) {
String resname = Sncp.getResourceName(service);
return "sncp.req.ws" + (resname.isEmpty() ? "" : ("-" + resname)) + ".node" + nodeid;
}
String resname = Sncp.getResourceName(service);
if (service instanceof WebSocketNode) return "sncp.req.ws" + (resname.isEmpty() ? "" : ("-" + resname));
return "sncp.req." + Sncp.getResourceType(service).getSimpleName().replaceAll("Service.*$", "").toLowerCase() + (resname.isEmpty() ? "" : ("-" + resname));
}
@@ -198,11 +201,6 @@ public abstract class MessageAgent {
}
//格式: ws.resp.wsgame.node100
public String generateWebSocketRespTopic(WebSocketNode node) {
return "ws.resp." + node.getName() + ".node" + nodeid;
}
//格式: xxxx.resp.node10
protected String generateRespTopic(String protocol) {
return protocol + ".resp.node" + nodeid;

View File

@@ -79,7 +79,7 @@ public abstract class WebSocketNode {
if (wsthreads == 0) wsthreads = Runtime.getRuntime().availableProcessors() * 8;
if (wsthreads > 0) this.semaphore = new Semaphore(wsthreads);
}
String mqtopic = this.messageAgent == null ? null : this.messageAgent.generateWebSocketRespTopic(this);
String mqtopic = this.messageAgent == null ? null : this.messageAgent.generateSncpReqTopic((Service)this);
if (mqtopic != null || this.localSncpAddress != null) {
this.wsaddress = new WebSocketAddress(mqtopic, localSncpAddress);
}