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, theMessageSinkmanages the demand until the conditions to invoke the application function are met; when theMessageSinkinvokes the application function, then the application is responsible to demand for more WebSocket frames. - If
autoDemand==true, only theMessageSinkmanages the demand for WebSocket frames. If theMessageSinkinvokes the application function, theMessageSinkmust 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
ConstructorsConstructorDescriptionAbstractMessageSink(CoreSession session, MethodHandle methodHandle, boolean autoDemand) Creates a newMessageSink. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidIfisAutoDemand()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.booleanMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MessageSink
accept, fail
-
Constructor Details
-
AbstractMessageSink
Creates a newMessageSink.- Parameters:
session- the WebSocket sessionmethodHandle- the application function to invokeautoDemand- whether thisMessageSinkmanages demand automatically as explained inAbstractMessageSink
-
-
Method Details
-
getCoreSession
-
getMethodHandle
Get the application function.- Returns:
- the application function
-
isAutoDemand
public boolean isAutoDemand()- Returns:
- whether this
MessageSinkautomatically 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.
-