in src/main/java/com/microsoft/azure/proton/transport/ws/impl/WebSocketImpl.java [482:552]
public int pending() {
if (isWebSocketEnabled) {
switch (webSocketState) {
case PN_WS_NOT_STARTED:
if (outputBuffer.position() == 0) {
webSocketState = WebSocketState.PN_WS_CONNECTING;
writeUpgradeRequest();
head.limit(outputBuffer.position());
if (headClosed) {
webSocketState = WebSocketState.PN_WS_FAILED;
return Transport.END_OF_STREAM;
} else {
return outputBuffer.position();
}
} else {
return outputBuffer.position();
}
case PN_WS_CONNECTING:
if (headClosed && (outputBuffer.position() == 0)) {
webSocketState = WebSocketState.PN_WS_FAILED;
return Transport.END_OF_STREAM;
} else {
return outputBuffer.position();
}
case PN_WS_CONNECTED_FLOW:
underlyingOutputSize = underlyingOutput.pending();
if (underlyingOutputSize > 0) {
webSocketHeaderSize = webSocketHandler.calculateHeaderSize(underlyingOutputSize);
return underlyingOutputSize + webSocketHeaderSize;
} else {
return underlyingOutputSize;
}
case PN_WS_CONNECTED_PONG:
webSocketState = WebSocketState.PN_WS_CONNECTED_FLOW;
writePong();
head.limit(outputBuffer.position());
if (headClosed) {
webSocketState = WebSocketState.PN_WS_FAILED;
return Transport.END_OF_STREAM;
} else {
return outputBuffer.position();
}
case PN_WS_CONNECTED_CLOSING:
webSocketState = WebSocketState.PN_WS_CLOSED;
writeClose();
head.limit(outputBuffer.position());
if (headClosed) {
webSocketState = WebSocketState.PN_WS_FAILED;
return Transport.END_OF_STREAM;
} else {
return outputBuffer.position();
}
case PN_WS_FAILED:
default:
return Transport.END_OF_STREAM;
}
} else {
return underlyingOutput.pending();
}
}