Class WebSocketCoreSession
- All Implemented Interfaces:
Dumpable, Configuration, CoreSession, IncomingFrames, OutgoingFrames
-
Nested Class Summary
Nested classes/interfaces inherited from interface Configuration
Configuration.ConfigurationCustomizer, Configuration.CustomizerNested classes/interfaces inherited from interface CoreSession
CoreSession.EmptyNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainer -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionWebSocketCoreSession(FrameHandler handler, Behavior behavior, Negotiated negotiated, WebSocketComponents components) -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Issue a harsh abort of the underlying connection.voidInitiate close handshake with provided status code and optional reason phrase.voidInitiate close handshake, no payload (no declared status code or reason phrase).voidclose(CloseStatus closeStatus, Callback callback) Initiate close handshake with a providedCloseStatus.voiddemand()Manages flow control by indicating demand for a WebSocket frame.dump()voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.voidGet the Idle TimeoutintThe Local Socket Address for the connectionlonglongintGet the maximum number of data frames allowed to be waiting to be sent at any one time.longThe negotiated WebSocket Extension Configurations for this session.intThe parameter map (from URI Query) for the active session.The activeSec-WebSocket-Version(protocol version) in use.The Remote Socket Address for the connectionThe active connection's Request URI.Get the Write Timeoutprotected voidCan be overridden to scope into the correct classloader before calling application code.booleanbooleanisClosed()booleanbooleanbooleanbooleanbooleanbooleanisSecure()The active connection's Secure status indicator.voidonEof()Used to notify theWebSocketCoreSessionthat EOF has been read or the connection has been closed.voidProcess the incoming frame.voidonOpen()Used to notify theWebSocketCoreSessionthat the connection has been opened.voidprocessConnectionError(Throwable cause, Callback callback) Process an Error that originated from the connection.voidprocessHandlerError(Throwable cause, Callback callback) Process an Error that originated from the handler.voidA frame, and optional callback, intended for the network layer.voidsetAutoFragment(boolean autoFragment) voidsetClassLoader(ClassLoader classLoader) voidsetIdleTimeout(Duration timeout) Set the Idle Timeout.voidsetInputBufferSize(int inputBufferSize) voidsetMaxBinaryMessageSize(long maxSize) voidsetMaxFrameSize(long maxFrameSize) voidsetMaxOutgoingFrames(int maxOutgoingFrames) Set the maximum number of data frames allowed to be waiting to be sent at any one time.voidsetMaxTextMessageSize(long maxSize) voidsetOutputBufferSize(int outputBufferSize) voidsetWebSocketConnection(WebSocketConnection connection) Used to set the WebSocketConnection on thisWebSocketCoreSession.voidsetWriteTimeout(Duration timeout) Set the Frame Write Timeout.toString()
-
Constructor Details
-
WebSocketCoreSession
public WebSocketCoreSession(FrameHandler handler, Behavior behavior, Negotiated negotiated, WebSocketComponents components)
-
-
Method Details
-
getClassLoader
-
setClassLoader
-
handle
Can be overridden to scope into the correct classloader before calling application code.- Parameters:
runnable- the runnable to execute.
-
getExtensionStack
-
getHandler
-
getNegotiatedSubProtocol
- Specified by:
getNegotiatedSubProtocolin interfaceCoreSession
-
getIdleTimeout
Description copied from interface:ConfigurationGet the Idle Timeout- Specified by:
getIdleTimeoutin interfaceConfiguration- Returns:
- the idle timeout
-
setIdleTimeout
Description copied from interface:ConfigurationSet the Idle Timeout.- Specified by:
setIdleTimeoutin interfaceConfiguration- Parameters:
timeout- the timeout duration (timeout <= 0 implies an infinite timeout)
-
getWriteTimeout
Description copied from interface:ConfigurationGet the Write Timeout- Specified by:
getWriteTimeoutin interfaceConfiguration- Returns:
- the write timeout
-
setWriteTimeout
Description copied from interface:ConfigurationSet the Frame Write Timeout.- Specified by:
setWriteTimeoutin interfaceConfiguration- Parameters:
timeout- the timeout duration (timeout <= 0 implies an infinite timeout)
-
getLocalAddress
Description copied from interface:CoreSessionThe Local Socket Address for the connectionDo not assume that this will return a
InetSocketAddressin all cases. Use of various proxies, and even UnixSockets can result a SocketAddress being returned without supportingInetSocketAddress- Specified by:
getLocalAddressin interfaceCoreSession- Returns:
- the SocketAddress for the local connection, or null if not supported by Session
-
getRemoteAddress
Description copied from interface:CoreSessionThe Remote Socket Address for the connectionDo not assume that this will return a
InetSocketAddressin all cases. Use of various proxies, and even UnixSockets can result a SocketAddress being returned without supportingInetSocketAddress- Specified by:
getRemoteAddressin interfaceCoreSession- Returns:
- the SocketAddress for the remote connection, or null if not supported by Session
-
isInputOpen
public boolean isInputOpen()- Specified by:
isInputOpenin interfaceCoreSession- Returns:
- True if the websocket is open inbound
-
isOutputOpen
public boolean isOutputOpen()- Specified by:
isOutputOpenin interfaceCoreSession- Returns:
- True if the websocket is open outbound
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceCoreSession
-
setWebSocketConnection
Used to set the WebSocketConnection on thisWebSocketCoreSession.- Parameters:
connection- the websocket connection.
-
close
Description copied from interface:CoreSessionInitiate close handshake, no payload (no declared status code or reason phrase).- Specified by:
closein interfaceCoreSession- Parameters:
callback- the callback to track close frame sent (or failed).
-
close
Description copied from interface:CoreSessionInitiate close handshake with provided status code and optional reason phrase.- Specified by:
closein interfaceCoreSession- Parameters:
statusCode- the status code (should be a valid status code that can be sent).reason- optional reason phrase (will be truncated automatically by implementation to fit within limits of protocol).callback- the callback to track close frame sent (or failed).
-
close
Description copied from interface:CoreSessionInitiate close handshake with a providedCloseStatus.- Specified by:
closein interfaceCoreSession- Parameters:
closeStatus- the close status containing (statusCode, reason, and optionalThrowablecause).callback- the callback to track close frame sent (or failed).
-
getByteBufferPool
- Specified by:
getByteBufferPoolin interfaceCoreSession- Returns:
- The shared ByteBufferPool
-
onEof
public void onEof()Used to notify theWebSocketCoreSessionthat EOF has been read or the connection has been closed. -
processConnectionError
-
processHandlerError
-
onOpen
public void onOpen()Used to notify theWebSocketCoreSessionthat the connection has been opened. -
demand
public void demand()Description copied from interface:CoreSessionManages flow control by indicating demand for a WebSocket frame.
A call to
FrameHandler.onFrame(Frame, Callback)will only be made if there is demand.If a previous demand has not been fulfilled this will throw
ReadPendingExceptionFrameHandler.onFrame(Frame, Callback).- Specified by:
demandin interfaceCoreSession
-
isRsv1Used
public boolean isRsv1Used()- Specified by:
isRsv1Usedin interfaceCoreSession- Returns:
- true if an extension has been negotiated which uses the RSV1 bit.
-
isRsv2Used
public boolean isRsv2Used()- Specified by:
isRsv2Usedin interfaceCoreSession- Returns:
- true if an extension has been negotiated which uses the RSV2 bit.
-
isRsv3Used
public boolean isRsv3Used()- Specified by:
isRsv3Usedin interfaceCoreSession- Returns:
- true if an extension has been negotiated which uses the RSV3 bit.
-
getConnection
-
getExecutor
-
onFrame
Description copied from interface:IncomingFramesProcess the incoming frame.
Note: if you need to hang onto any information from the frame, be sure to copy it, as the information contained in the Frame will be released and/or reused by the implementation.
Failure of the callback will propagate the failure back to the
CoreSessionto fail the connection and attempt to send a closeFrameif one has not been sent.- Specified by:
onFramein interfaceIncomingFrames- Parameters:
frame- the frame to process.callback- the read completion.
-
sendFrame
Description copied from interface:OutgoingFramesA frame, and optional callback, intended for the network layer.Note: the frame can undergo many transformations in the various layers and extensions present in the implementation.
If you are implementing a mutation, you are obliged to handle the incoming Callback appropriately.
- Specified by:
sendFramein interfaceOutgoingFrames- Parameters:
frame- the frame to eventually write to the network layer.callback- the callback to notify when the frame is written.batch- the batch mode requested by the sender.
-
flush
- Specified by:
flushin interfaceCoreSession
-
abort
public void abort()Description copied from interface:CoreSessionIssue a harsh abort of the underlying connection.This will terminate the connection, without sending a websocket close frame. No WebSocket Protocol close handshake will be performed.
Once called, any read/write activity on the websocket from this point will be indeterminate. This can result in the
FrameHandler.onError(Throwable, Callback)event being called indicating any issue that arises.Once the underlying connection has been determined to be closed, the
FrameHandler.onClosed(CloseStatus, Callback)event will be called.- Specified by:
abortin interfaceCoreSession
-
isAutoFragment
public boolean isAutoFragment()- Specified by:
isAutoFragmentin interfaceConfiguration
-
setAutoFragment
public void setAutoFragment(boolean autoFragment) - Specified by:
setAutoFragmentin interfaceConfiguration
-
getMaxFrameSize
public long getMaxFrameSize()- Specified by:
getMaxFrameSizein interfaceConfiguration
-
setMaxFrameSize
public void setMaxFrameSize(long maxFrameSize) - Specified by:
setMaxFrameSizein interfaceConfiguration
-
getOutputBufferSize
public int getOutputBufferSize()- Specified by:
getOutputBufferSizein interfaceConfiguration
-
setOutputBufferSize
public void setOutputBufferSize(int outputBufferSize) - Specified by:
setOutputBufferSizein interfaceConfiguration
-
getInputBufferSize
public int getInputBufferSize()- Specified by:
getInputBufferSizein interfaceConfiguration
-
setInputBufferSize
public void setInputBufferSize(int inputBufferSize) - Specified by:
setInputBufferSizein interfaceConfiguration
-
getMaxBinaryMessageSize
public long getMaxBinaryMessageSize()- Specified by:
getMaxBinaryMessageSizein interfaceConfiguration
-
setMaxBinaryMessageSize
public void setMaxBinaryMessageSize(long maxSize) - Specified by:
setMaxBinaryMessageSizein interfaceConfiguration
-
getMaxTextMessageSize
public long getMaxTextMessageSize()- Specified by:
getMaxTextMessageSizein interfaceConfiguration
-
setMaxTextMessageSize
public void setMaxTextMessageSize(long maxSize) - Specified by:
setMaxTextMessageSizein interfaceConfiguration
-
getMaxOutgoingFrames
public int getMaxOutgoingFrames()Description copied from interface:ConfigurationGet the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with aWritePendingExceptionbut the connection is not failed and will remain open.- Specified by:
getMaxOutgoingFramesin interfaceConfiguration- Returns:
- the max number of frames.
-
setMaxOutgoingFrames
public void setMaxOutgoingFrames(int maxOutgoingFrames) Description copied from interface:ConfigurationSet the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with aWritePendingExceptionbut the connection is not failed and will remain open.- Specified by:
setMaxOutgoingFramesin interfaceConfiguration- Parameters:
maxOutgoingFrames- the max number of frames.
-
dump
-
dump
Description copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
dumpin interfaceDumpable- Parameters:
out- The appendable to dump toindent- The indent to apply after any new lines.- Throws:
IOException- if unable to write to Appendable
-
getNegotiatedExtensions
Description copied from interface:CoreSessionThe negotiated WebSocket Extension Configurations for this session.- Specified by:
getNegotiatedExtensionsin interfaceCoreSession- Returns:
- the list of Negotiated Extension Configurations for this session.
-
getParameterMap
Description copied from interface:CoreSessionThe parameter map (from URI Query) for the active session.- Specified by:
getParameterMapin interfaceCoreSession- Returns:
- the immutable map of parameters
-
getProtocolVersion
Description copied from interface:CoreSessionThe activeSec-WebSocket-Version(protocol version) in use.- Specified by:
getProtocolVersionin interfaceCoreSession- Returns:
- the protocol version in use.
-
getRequestURI
Description copied from interface:CoreSessionThe active connection's Request URI. This is the URI of the upgrade request and is typically http: or https: rather than the ws: or wss: scheme.- Specified by:
getRequestURIin interfaceCoreSession- Returns:
- the absolute URI (including Query string)
-
isSecure
public boolean isSecure()Description copied from interface:CoreSessionThe active connection's Secure status indicator.- Specified by:
isSecurein interfaceCoreSession- Returns:
- true if connection is secure (similar in role to
HttpServletRequest.isSecure())
-
getBehavior
- Specified by:
getBehaviorin interfaceCoreSession- Returns:
- Client or Server behaviour
-
getWebSocketComponents
- Specified by:
getWebSocketComponentsin interfaceCoreSession- Returns:
- the WebSocketComponents instance in use for this Connection.
-
toString
-