use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class BlockheadClient method close.
/* (non-Javadoc)
* @see org.eclipse.jetty.websocket.common.test.IBlockheadClient#close(int, java.lang.String)
*/
@Override
public void close(int statusCode, String message) {
LOG.debug("close({},{})", statusCode, message);
CloseInfo close = new CloseInfo(statusCode, message);
if (!ioState.isClosed()) {
ioState.onCloseLocal(close);
} else {
LOG.debug("Not issuing close. ioState = {}", ioState);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class LocalWebSocketConnection method close.
@Override
public void close(int statusCode, String reason) {
if (LOG.isDebugEnabled())
LOG.debug("close({}, {})", statusCode, reason);
CloseInfo close = new CloseInfo(statusCode, reason);
ioState.onCloseLocal(close);
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class LocalWebSocketConnection method onConnectionStateChange.
@Override
public void onConnectionStateChange(ConnectionState state) {
if (LOG.isDebugEnabled())
LOG.debug("Connection State Change: {}", state);
switch(state) {
case CLOSED:
this.disconnect();
break;
case CLOSING:
if (ioState.wasRemoteCloseInitiated()) {
// send response close frame
CloseInfo close = ioState.getCloseInfo();
LOG.debug("write close frame: {}", close);
ioState.onCloseLocal(close);
}
default:
break;
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class IOStateTest method testConnectAbnormalClose.
@Test
public void testConnectAbnormalClose() {
IOState state = new IOState();
StateTracker tracker = new StateTracker();
state.addListener(tracker);
assertState(state, ConnectionState.CONNECTING);
// connect
state.onConnected();
assertInputAvailable(state, false);
assertOutputAvailable(state, true);
// open
state.onOpened();
assertInputAvailable(state, true);
assertOutputAvailable(state, true);
// disconnect
state.onAbnormalClose(new CloseInfo(StatusCode.NO_CLOSE, "Oops"));
assertInputAvailable(state, false);
assertOutputAvailable(state, false);
tracker.assertTransitions(ConnectionState.CONNECTED, ConnectionState.OPEN, ConnectionState.CLOSED);
assertState(state, ConnectionState.CLOSED);
// not clean
assertCleanClose(state, false);
assertLocalInitiated(state, false);
assertRemoteInitiated(state, false);
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class EventDriverTest method testAnnotated_ByteArray.
@Test
public void testAnnotated_ByteArray() throws Exception {
AnnotatedBinaryArraySocket socket = new AnnotatedBinaryArraySocket();
EventDriver driver = wrap(socket);
try (LocalWebSocketSession conn = new CloseableLocalWebSocketSession(container, testname, driver)) {
conn.open();
driver.incomingFrame(makeBinaryFrame("Hello World", true));
driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame());
socket.capture.assertEventCount(3);
socket.capture.pop().assertEventStartsWith("onConnect");
socket.capture.pop().assertEvent("onBinary([11],0,11)");
socket.capture.pop().assertEventStartsWith("onClose(1000,");
}
}
Aggregations