Top Description Fields Constructors Methods
org.eclipse.jetty.websocket.core.messages

public abstract Class AbstractMessageSink

extends Object
implements MessageSink
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.websocket.core.messages.MessageSink
Known Direct Subclasses
org.eclipse.jetty.websocket.core.messages.ByteArrayMessageSink, org.eclipse.jetty.websocket.core.messages.ByteBufferMessageSink, org.eclipse.jetty.websocket.core.messages.DispatchedMessageSink, org.eclipse.jetty.websocket.core.messages.PartialByteArrayMessageSink, org.eclipse.jetty.websocket.core.messages.PartialByteBufferMessageSink, org.eclipse.jetty.websocket.core.messages.PartialStringMessageSink, org.eclipse.jetty.websocket.core.messages.StringMessageSink
Imports
java.lang.invoke.MethodHandle, java.util.Objects, org.eclipse.jetty.websocket.core.CoreSession

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:

Method autoDemand() helps to manage the demand after the invocation of the application function returns successfully.

Field Summary

Modifier and TypeField and Description
private final boolean
private final MethodHandle
private final CoreSession

Constructor Summary

AccessConstructor and Description
public
AbstractMessageSink(CoreSession
the WebSocket session
session
,
MethodHandle
the application function to invoke
methodHandle
,
boolean
whether this MessageSink manages demand automatically as explained in AbstractMessageSink
autoDemand
)

Creates a new MessageSink.

Method Summary

Modifier and TypeMethod and Description
protected void
autoDemand()

If isAutoDemand() then demands for one more WebSocket frame via CoreSession#demand(); otherwise it is a no-operation, because the demand is explicitly managed by the application function.

public CoreSession

Returns:

the WebSocket session
getCoreSession
()

Get the WebSocket session.

public MethodHandle

Returns:

the application function
getMethodHandle
()

Get the application function.

public boolean
isAutoDemand()

Returns: whether this MessageSink automatically demands for more WebSocket frames after the invocation of the application function has returned.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoDemandback to summary
private final boolean autoDemand
methodHandleback to summary
private final MethodHandle methodHandle
sessionback to summary
private final CoreSession session

Constructor Detail

AbstractMessageSinkback to summary
public AbstractMessageSink(CoreSession session, MethodHandle methodHandle, boolean autoDemand)

Creates a new MessageSink.

Parameters
session:CoreSession

the WebSocket session

methodHandle:MethodHandle

the application function to invoke

autoDemand:boolean

whether this MessageSink manages demand automatically as explained in AbstractMessageSink

Method Detail

autoDemandback to summary
protected void autoDemand()

If isAutoDemand() then demands for one more WebSocket frame via CoreSession#demand(); otherwise it is a no-operation, because the demand is explicitly managed by the application function.

getCoreSessionback to summary
public CoreSession getCoreSession()

Get the WebSocket session.

Returns:CoreSession

the WebSocket session

getMethodHandleback to summary
public MethodHandle getMethodHandle()

Get the application function.

Returns:MethodHandle

the application function

isAutoDemandback to summary
public boolean isAutoDemand()
Returns:boolean

whether this MessageSink automatically demands for more WebSocket frames after the invocation of the application function has returned.