Class JettyWebSocketFrameHandler
- java.lang.Object
-
- org.eclipse.jetty.websocket.common.JettyWebSocketFrameHandler
-
- All Implemented Interfaces:
FrameHandler,IncomingFrames
public class JettyWebSocketFrameHandler extends java.lang.Object implements FrameHandler
-
-
Constructor Summary
Constructors Constructor Description JettyWebSocketFrameHandler(WebSocketContainer container, java.lang.Object endpointInstance, java.lang.invoke.MethodHandle openHandle, java.lang.invoke.MethodHandle closeHandle, java.lang.invoke.MethodHandle errorHandle, java.lang.invoke.MethodHandle textHandle, java.lang.invoke.MethodHandle binaryHandle, java.lang.Class<? extends MessageSink> textSinkClass, java.lang.Class<? extends MessageSink> binarySinkClass, java.lang.invoke.MethodHandle frameHandle, java.lang.invoke.MethodHandle pingHandle, java.lang.invoke.MethodHandle pongHandle, BatchMode batchMode, Configuration.Customizer customizer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.ThrowableconvertCause(java.lang.Throwable cause)BatchModegetBatchMode()WebSocketSessiongetSession()UpgradeRequestgetUpgradeRequest()UpgradeResponsegetUpgradeResponse()booleanisDemanding()Does the FrameHandler manage it's own demand?voidonClosed(CloseStatus closeStatus, Callback callback)This is the Close Handshake Complete event.voidonError(java.lang.Throwable cause, Callback callback)An error has occurred or been detected in websocket-core and being reported to FrameHandler.voidonFrame(Frame frame, Callback callback)Receiver of all Frames.voidonOpen(CoreSession coreSession, Callback callback)Async notification that Connection is being opened.voidresume()voidsetUpgradeRequest(UpgradeRequest upgradeRequest)voidsetUpgradeResponse(UpgradeResponse upgradeResponse)voidsuspend()java.lang.StringtoString()
-
-
-
Constructor Detail
-
JettyWebSocketFrameHandler
public JettyWebSocketFrameHandler(WebSocketContainer container, java.lang.Object endpointInstance, java.lang.invoke.MethodHandle openHandle, java.lang.invoke.MethodHandle closeHandle, java.lang.invoke.MethodHandle errorHandle, java.lang.invoke.MethodHandle textHandle, java.lang.invoke.MethodHandle binaryHandle, java.lang.Class<? extends MessageSink> textSinkClass, java.lang.Class<? extends MessageSink> binarySinkClass, java.lang.invoke.MethodHandle frameHandle, java.lang.invoke.MethodHandle pingHandle, java.lang.invoke.MethodHandle pongHandle, BatchMode batchMode, Configuration.Customizer customizer)
-
-
Method Detail
-
setUpgradeRequest
public void setUpgradeRequest(UpgradeRequest upgradeRequest)
-
setUpgradeResponse
public void setUpgradeResponse(UpgradeResponse upgradeResponse)
-
getUpgradeRequest
public UpgradeRequest getUpgradeRequest()
-
getUpgradeResponse
public UpgradeResponse getUpgradeResponse()
-
getBatchMode
public BatchMode getBatchMode()
-
getSession
public WebSocketSession getSession()
-
onOpen
public void onOpen(CoreSession coreSession, Callback callback)
Description copied from interface:FrameHandlerAsync notification that Connection is being opened.FrameHandler can write during this call, but can not receive frames until the callback is succeeded.
If the FrameHandler succeeds the callback we transition to OPEN state and can now receive frames if not demanding, or can now call
CoreSession.demand(long)to receive frames if demanding. If the FrameHandler fails the callback a close frame will be sent withCloseStatus.SERVER_ERRORand the connection will be closed.
- Specified by:
onOpenin interfaceFrameHandler- Parameters:
coreSession- the session associated with this connection.callback- the callback to indicate success in processing (or failure)
-
onFrame
public void onFrame(Frame frame, Callback callback)
Description copied from interface:FrameHandlerReceiver of all Frames. This method will never be called in parallel for the same session and will be called sequentially to satisfy all outstanding demand signaled by calls toCoreSession.demand(long). Control and Data frames are passed to this method. Close frames may be responded to by the handler, but if an appropriate close response is not sent once the callback is succeeded, then a response close will be generated and sent.- Specified by:
onFramein interfaceFrameHandler- Specified by:
onFramein interfaceIncomingFrames- Parameters:
frame- the raw framecallback- the callback to indicate success in processing frame (or failure)
-
onError
public void onError(java.lang.Throwable cause, Callback callback)Description copied from interface:FrameHandlerAn error has occurred or been detected in websocket-core and being reported to FrameHandler. A call to onError will be followed by a call toFrameHandler.onClosed(CloseStatus, Callback)giving the close status derived from the error. This will not be called more than once,FrameHandler.onClosed(CloseStatus, Callback)will be called on the callback completion.- Specified by:
onErrorin interfaceFrameHandler- Parameters:
cause- the reason for the errorcallback- the callback to indicate success in processing (or failure)
-
onClosed
public void onClosed(CloseStatus closeStatus, Callback callback)
Description copied from interface:FrameHandlerThis is the Close Handshake Complete event.The connection is now closed, no reading or writing is possible anymore. Implementations of FrameHandler can cleanup their resources for this connection now. This method will be called only once.
- Specified by:
onClosedin interfaceFrameHandler- Parameters:
closeStatus- the close status received from remote, or in the case of abnormal closure from local.callback- the callback to indicate success in processing (or failure)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isDemanding
public boolean isDemanding()
Description copied from interface:FrameHandlerDoes the FrameHandler manage it's own demand?- Specified by:
isDemandingin interfaceFrameHandler- Returns:
- true iff the FrameHandler will manage its own flow control by calling
CoreSession.demand(long)when it is willing to receive new Frames. Otherwise the demand will be managed by an automatic call to demand(1) after every succeeded callback passed toFrameHandler.onFrame(Frame, Callback).
-
suspend
public void suspend()
-
resume
public void resume()
-
convertCause
public static java.lang.Throwable convertCause(java.lang.Throwable cause)
-
-