WebSocket增加getSncpAddress方法,获取分布式下的sncp地址

This commit is contained in:
Redkale
2019-08-28 12:56:50 +08:00
parent 70a75abf74
commit b0deed2a89
2 changed files with 12 additions and 0 deletions

View File

@@ -83,6 +83,8 @@ public abstract class WebSocket<G extends Serializable, T> {
WebSocketEngine _engine; //不可能为空
InetSocketAddress _sncpAddress; //分布式下不可为空
AsyncConnection _channel;//不可能为空
String _sessionid; //不可能为空
@@ -826,6 +828,15 @@ public abstract class WebSocket<G extends Serializable, T> {
return forceCloseWebSocket(getUserid()).thenApply((r) -> true);
}
/**
* 获取分布式情况下的SNCP地址, 非分布式下为null
*
* @return InetSocketAddress sncpAddress
*/
public InetSocketAddress getSncpAddress() {
return _sncpAddress;
}
/**
* 获取Logger
*

View File

@@ -209,6 +209,7 @@ public abstract class WebSocketServlet extends HttpServlet implements Resourcabl
webSocket._sendConvert = sendConvert;
webSocket._remoteAddress = request.getRemoteAddress();
webSocket._remoteAddr = request.getRemoteAddr();
webSocket._sncpAddress = this.node.localSncpAddress;
initRestWebSocket(webSocket);
CompletableFuture<String> sessionFuture = webSocket.onOpen(request);
if (sessionFuture == null) {