Making autobahn server disconnect happy
This commit is contained in:
parent
73fd838b41
commit
ebe98022ab
|
@ -141,6 +141,21 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
return String.format("%s@%x",FlushInvoker.class.getSimpleName(),hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
public class OnDisconnectCallback implements WriteCallback
|
||||
{
|
||||
@Override
|
||||
public void writeFailed(Throwable x)
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSuccess()
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Stats
|
||||
{
|
||||
|
@ -233,6 +248,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
@Override
|
||||
public void disconnect()
|
||||
{
|
||||
LOG.debug("{} disconnect()", policy.getBehavior());
|
||||
synchronized (writeBytes)
|
||||
{
|
||||
if (!writeBytes.isClosed())
|
||||
|
@ -426,7 +442,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
@Override
|
||||
public void onConnectionStateChange(ConnectionState state)
|
||||
{
|
||||
LOG.debug("Connection State Change: {}",state);
|
||||
LOG.debug("{} Connection State Change: {}",policy.getBehavior(),state);
|
||||
switch (state)
|
||||
{
|
||||
case OPEN:
|
||||
|
@ -439,7 +455,7 @@ public abstract class AbstractWebSocketConnection extends AbstractConnection imp
|
|||
case CLOSING:
|
||||
CloseInfo close = ioState.getCloseInfo();
|
||||
// append close frame
|
||||
outgoingFrame(close.asFrame(),null);
|
||||
outgoingFrame(close.asFrame(),new OnDisconnectCallback());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -182,11 +182,13 @@ public class IOState
|
|||
*/
|
||||
public void onCloseLocal(CloseInfo close)
|
||||
{
|
||||
LOG.debug("onCloseLocal({})",close);
|
||||
ConnectionState event = null;
|
||||
ConnectionState initialState = this.state;
|
||||
if (initialState == ConnectionState.CLOSED)
|
||||
{
|
||||
// already closed
|
||||
LOG.debug("already closed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -224,10 +226,13 @@ public class IOState
|
|||
event = this.state;
|
||||
}
|
||||
}
|
||||
|
||||
LOG.debug("event = {}",event);
|
||||
|
||||
// Only notify on state change events
|
||||
if (event != null)
|
||||
{
|
||||
LOG.debug("notifying state listeners: {}",event);
|
||||
notifyStateListeners(event);
|
||||
|
||||
// if harsh, we don't expect an answer.
|
||||
|
@ -254,6 +259,7 @@ public class IOState
|
|||
*/
|
||||
public void onCloseRemote(CloseInfo close)
|
||||
{
|
||||
LOG.debug("onCloseRemote({})",close);
|
||||
ConnectionState event = null;
|
||||
synchronized (this.state)
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.eclipse.jetty.io.EndPoint;
|
|||
import org.eclipse.jetty.util.thread.Scheduler;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketPolicy;
|
||||
import org.eclipse.jetty.websocket.api.extensions.IncomingFrames;
|
||||
import org.eclipse.jetty.websocket.common.ConnectionState;
|
||||
import org.eclipse.jetty.websocket.common.io.AbstractWebSocketConnection;
|
||||
|
||||
public class WebSocketServerConnection extends AbstractWebSocketConnection
|
||||
|
@ -74,7 +75,7 @@ public class WebSocketServerConnection extends AbstractWebSocketConnection
|
|||
}
|
||||
super.onOpen();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setNextIncomingFrames(IncomingFrames incoming)
|
||||
{
|
||||
|
|
|
@ -51,6 +51,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -82,6 +83,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -113,6 +115,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -144,6 +147,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -175,6 +179,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -206,6 +211,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -237,6 +243,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -274,6 +281,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSlowSendSegmentSize(segmentSize);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -302,6 +310,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -333,6 +342,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -364,6 +374,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -395,6 +406,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -426,6 +438,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -457,6 +470,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -488,6 +502,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSendMode(SendMode.BULK);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -525,6 +540,7 @@ public class TestABCase1 extends AbstractABCase
|
|||
fuzzer.setSlowSendSegmentSize(segmentSize);
|
||||
fuzzer.send(send);
|
||||
fuzzer.expect(expect);
|
||||
fuzzer.expectServerDisconnect(Fuzzer.DisconnectMode.CLEAN);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue