Class IOState
- java.lang.Object
-
- org.eclipse.jetty.websocket.common.io.IOState
-
public class IOState extends Object
Simple state tracker for Input / Output andConnectionState.Use the various known .on*() methods to trigger a state change.
onOpened()- connection has been opened
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceIOState.ConnectionStateListener
-
Constructor Summary
Constructors Constructor Description IOState()Create a new IOState, initialized toConnectionState.CONNECTING
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(IOState.ConnectionStateListener listener)voidassertInputOpen()voidassertOutputOpen()CloseInfogetCloseInfo()ConnectionStategetConnectionState()booleanisClosed()booleanisInputAvailable()booleanisOpen()booleanisOutputAvailable()voidonAbnormalClose(CloseInfo close)A websocket connection has been disconnected for abnormal close reasons.voidonCloseLocal(CloseInfo closeInfo)A close handshake has been issued from the local endpointvoidonCloseRemote(CloseInfo closeInfo)A close handshake has been received from the remote endpointvoidonConnected()WebSocket has successfully upgraded, but the end-user onOpen call hasn't run yet.voidonDisconnected()voidonFailedUpgrade()A websocket connection has failed its upgrade handshake, and is now closed.voidonOpened()A websocket connection has finished its upgrade handshake, and is now open.voidonReadFailure(Throwable t)The local endpoint has reached a read failure.voidonWriteFailure(Throwable t)The local endpoint has reached a write failure.StringtoString()booleanwasAbnormalClose()booleanwasCleanClose()booleanwasLocalCloseInitiated()booleanwasRemoteCloseInitiated()
-
-
-
Constructor Detail
-
IOState
public IOState()
Create a new IOState, initialized toConnectionState.CONNECTING
-
-
Method Detail
-
addListener
public void addListener(IOState.ConnectionStateListener listener)
-
assertInputOpen
public void assertInputOpen() throws IOException- Throws:
IOException
-
assertOutputOpen
public void assertOutputOpen() throws IOException- Throws:
IOException
-
getCloseInfo
public CloseInfo getCloseInfo()
-
getConnectionState
public ConnectionState getConnectionState()
-
isClosed
public boolean isClosed()
-
isInputAvailable
public boolean isInputAvailable()
-
isOpen
public boolean isOpen()
-
isOutputAvailable
public boolean isOutputAvailable()
-
onAbnormalClose
public void onAbnormalClose(CloseInfo close)
A websocket connection has been disconnected for abnormal close reasons.This is the low level disconnect of the socket. It could be the result of a normal close operation, from an IO error, or even from a timeout.
- Parameters:
close- the close information
-
onCloseLocal
public void onCloseLocal(CloseInfo closeInfo)
A close handshake has been issued from the local endpoint- Parameters:
closeInfo- the close information
-
onCloseRemote
public void onCloseRemote(CloseInfo closeInfo)
A close handshake has been received from the remote endpoint- Parameters:
closeInfo- the close information
-
onConnected
public void onConnected()
WebSocket has successfully upgraded, but the end-user onOpen call hasn't run yet.This is an intermediate state between the RFC's
ConnectionState.CONNECTINGandConnectionState.OPEN
-
onFailedUpgrade
public void onFailedUpgrade()
A websocket connection has failed its upgrade handshake, and is now closed.
-
onOpened
public void onOpened()
A websocket connection has finished its upgrade handshake, and is now open.
-
onReadFailure
public void onReadFailure(Throwable t)
The local endpoint has reached a read failure.This could be a normal result after a proper close handshake, or even a premature close due to a connection disconnect.
- Parameters:
t- the read failure
-
onWriteFailure
public void onWriteFailure(Throwable t)
The local endpoint has reached a write failure.A low level I/O failure, or even a jetty side EndPoint close (from idle timeout) are a few scenarios
- Parameters:
t- the throwable that caused the write failure
-
onDisconnected
public void onDisconnected()
-
wasAbnormalClose
public boolean wasAbnormalClose()
-
wasCleanClose
public boolean wasCleanClose()
-
wasLocalCloseInitiated
public boolean wasLocalCloseInitiated()
-
wasRemoteCloseInitiated
public boolean wasRemoteCloseInitiated()
-
-