Issue #3479 - implement getInetSocketAddress() and flush()

deprecate old getInetSocketAddress() and add getRemoteAddress()

Signed-off-by: lachan-roberts <lachlan@webtide.com>
This commit is contained in:
lachan-roberts 2019-04-11 09:12:24 +10:00 committed by Greg Wilkins
parent f42ef1356e
commit 04f0872913
2 changed files with 26 additions and 2 deletions

View File

@ -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.
*

View File

@ -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();
}
}
}