Merge branch 'jetty-9.3.x'
This commit is contained in:
commit
0fe1bbcd91
|
@ -31,6 +31,7 @@ public class EchoHandler extends WebSocketHandler implements WebSocketCreator
|
|||
@Override
|
||||
public void configure(WebSocketServletFactory factory)
|
||||
{
|
||||
factory.getPolicy().setMaxTextMessageSize(2 * 1024 * 1024);
|
||||
factory.setCreator(this);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@ public class JettyEchoSocket extends WebSocketAdapter
|
|||
@Override
|
||||
public void onWebSocketBinary(byte[] payload, int offset, int len)
|
||||
{
|
||||
if (isNotConnected())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
RemoteEndpoint remote = getRemote();
|
||||
|
@ -60,6 +63,9 @@ public class JettyEchoSocket extends WebSocketAdapter
|
|||
@Override
|
||||
public void onWebSocketText(String message)
|
||||
{
|
||||
if (isNotConnected())
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
RemoteEndpoint remote = getRemote();
|
||||
|
|
|
@ -68,6 +68,7 @@ public class MessageReceivingTest {
|
|||
public static void startServer() throws Exception {
|
||||
server = new Server();
|
||||
ServerConnector connector = new ServerConnector(server);
|
||||
connector.setPort(0);
|
||||
server.addConnector(connector);
|
||||
|
||||
handler = new EchoHandler();
|
||||
|
|
|
@ -26,11 +26,11 @@ package org.eclipse.jetty.websocket.api;
|
|||
public class WebSocketAdapter implements WebSocketListener
|
||||
{
|
||||
private volatile Session session;
|
||||
private RemoteEndpoint remote;
|
||||
|
||||
public RemoteEndpoint getRemote()
|
||||
{
|
||||
Session sess = this.session;
|
||||
return sess == null?null:session.getRemote();
|
||||
return remote;
|
||||
}
|
||||
|
||||
public Session getSession()
|
||||
|
@ -60,12 +60,14 @@ public class WebSocketAdapter implements WebSocketListener
|
|||
public void onWebSocketClose(int statusCode, String reason)
|
||||
{
|
||||
this.session = null;
|
||||
this.remote = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnect(Session sess)
|
||||
{
|
||||
this.session = sess;
|
||||
this.remote = sess.getRemote();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue