Class AbstractMessageSink
java.lang.Object
org.eclipse.jetty.websocket.core.messages.AbstractMessageSink
- All Implemented Interfaces:
MessageSink
- Direct Known Subclasses:
ByteArrayMessageSink
,ByteBufferMessageSink
,DispatchedMessageSink
,PartialByteArrayMessageSink
,PartialByteBufferMessageSink
,PartialStringMessageSink
,StringMessageSink
Abstract implementation of MessageSink
.
Management of demand for WebSocket frames may either be entirely managed
by the MessageSink
implementation (autoDemand==true
); or
it may be managed collaboratively between the application and the
MessageSink
implementation (autoDemand==true
).
MessageSink
implementations must handle the demand for WebSocket
frames in this way:
- If
autoDemand==false
, theMessageSink
manages the demand until the conditions to invoke the application function are met; when theMessageSink
invokes the application function, then the application is responsible to demand for more WebSocket frames. - If
autoDemand==true
, only theMessageSink
manages the demand for WebSocket frames. If theMessageSink
invokes the application function, theMessageSink
must demand for WebSocket frames after the invocation of the application function returns successfully.
Method autoDemand()
helps to manage the demand after the
invocation of the application function returns successfully.
-
Constructor Summary
ConstructorDescriptionAbstractMessageSink
(CoreSession session, MethodHandle methodHandle, boolean autoDemand) Creates a newMessageSink
. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
IfisAutoDemand()
then demands for one more WebSocket frame viaCoreSession.demand()
; otherwise it is a no-operation, because the demand is explicitly managed by the application function.Get the WebSocket session.Get the application function.boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.websocket.core.messages.MessageSink
accept, fail
-
Constructor Details
-
AbstractMessageSink
Creates a newMessageSink
.- Parameters:
session
- the WebSocket sessionmethodHandle
- the application function to invokeautoDemand
- whether thisMessageSink
manages demand automatically as explained inAbstractMessageSink
-
-
Method Details
-
getCoreSession
Get the WebSocket session.- Returns:
- the WebSocket session
-
getMethodHandle
Get the application function.- Returns:
- the application function
-
isAutoDemand
public boolean isAutoDemand()- Returns:
- whether this
MessageSink
automatically demands for more WebSocket frames after the invocation of the application function has returned.
-
autoDemand
protected void autoDemand()If
isAutoDemand()
then demands for one more WebSocket frame viaCoreSession.demand()
; otherwise it is a no-operation, because the demand is explicitly managed by the application function.
-