diff --git a/jetty-websocket/jetty-websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java b/jetty-websocket/jetty-websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java index 0086e0ab45f..d366a9cb37e 100644 --- a/jetty-websocket/jetty-websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java +++ b/jetty-websocket/jetty-websocket-api/src/main/java/org/eclipse/jetty/websocket/api/RemoteEndpoint.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.api; import java.io.IOException; import java.net.InetSocketAddress; +import java.net.SocketAddress; import java.nio.ByteBuffer; import java.util.concurrent.Future; @@ -144,10 +145,18 @@ public interface RemoteEndpoint /** * Get the InetSocketAddress for the established connection. * - * @return the InetSocketAddress for the established connection. (or null, if the connection is no longer established) + * @return the InetSocketAddress for the established connection. (or null, if there is none) */ + @Deprecated InetSocketAddress getInetSocketAddress(); + /** + * Get the SocketAddress for the established connection. + * + * @return the SocketAddress for the established connection. + */ + SocketAddress getRemoteAddress(); + /** * Flushes messages that may have been batched by the implementation. * diff --git a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java index 7e67ed971cf..0d9f78cd550 100644 --- a/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java +++ b/jetty-websocket/jetty-websocket-common/src/main/java/org/eclipse/jetty/websocket/common/JettyWebSocketRemoteEndpoint.java @@ -20,6 +20,7 @@ package org.eclipse.jetty.websocket.common; import java.io.IOException; import java.net.InetSocketAddress; +import java.net.SocketAddress; import java.nio.ByteBuffer; import java.util.Objects; import java.util.concurrent.Future; @@ -255,12 +256,26 @@ public class JettyWebSocketRemoteEndpoint implements org.eclipse.jetty.websocket @Override public InetSocketAddress getInetSocketAddress() { + SocketAddress remoteAddress = coreSession.getRemoteAddress(); + if (remoteAddress instanceof InetSocketAddress) + return (InetSocketAddress)remoteAddress; + return null; } + @Override + public SocketAddress getRemoteAddress() + { + return coreSession.getRemoteAddress(); + } + @Override public void flush() throws IOException { - + try (SharedBlockingCallback.Blocker b = blocker.acquire()) + { + coreSession.flush(b); + b.block(); + } } }