public class DefaultWebSocketSessionConfig extends DefaultSessionConfig implements IWebSocketSessionConfig
HANDSHAKE_DECODER, HANDSHAKE_ENCODER, WEBSOCKET_DECODER, WEBSOCKET_ENCODER, WEBSOCKET_UTF8_VALIDATOR
Constructor and Description |
---|
DefaultWebSocketSessionConfig()
Constructs the default Web Socket configuration for a server session
|
DefaultWebSocketSessionConfig(URI requestUri)
Constructs the default Web Socket configuration for a client session
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptRequestUri(URI requestUri)
Determines if a received Web Socket handshake request with given request URI
should be accepted by the server session associated with this configuration
object.
|
ICodecExecutor |
createCodecExecutor()
Creates a new codec executor that will be responsible for decoding and
encoding data read/received and written/send in the associated session.
|
void |
customizeHeaders(HandshakeRequest request)
Called when the Web Socket handshake request is ready to be sent and can be
now customized, if needed.
|
void |
customizeHeaders(HandshakeResponse response)
Called when the Web Socket handshake response is ready to be sent and can be
now customized, if needed.
|
int |
getMaxFramePayloadLength()
Determines the maximum length of the payload in the decoded Web Socket
frames.
|
int |
getMaxHandshakeFrameLength()
Determines the maximum length of the decoded Web Socket handshake frames.
|
String |
getRequestOrigin()
Determines the value of the Origin header field in the client Web Socket
handshake request.
|
URI |
getRequestUri()
Determines the request URI (the server endpoint) in the client Web Socket
handshake request.
|
IExtension[] |
getSupportedExtensions()
Determines the supported extensions for both the server and client
Web Socket sessions.
|
String[] |
getSupportedSubProtocols()
Determines the names of supported subprotocols for both the server and client
Web Socket sessions.
|
boolean |
handleCloseFrame()
Determines if the received Web Socket close frames should be handled
automatically.
|
boolean |
ignoreHostHeaderField()
Determines if the server session associated with this configuration object
should ignore missing the Host header field in the received Web Socket
handshake request.
|
boolean |
isClientMode()
Tells if this configuration is for a client or server session.
|
DefaultWebSocketSessionConfig |
setHandleCloseFrame(boolean handleCloseFrame)
Configures if the received Web Socket close frames should be handled
automatically.
|
DefaultWebSocketSessionConfig |
setIgnoreHostHeaderField(boolean ignoreHostHeaderField)
Configures if the server session associated with this configuration object
should ignore missing the Host header field in the received Web Socket
handshake request.
|
DefaultWebSocketSessionConfig |
setMaxFramePayloadLength(int maxFramePayloadLength)
Sets the maximum length of the payload in the decoded Web Socket frames.
|
DefaultWebSocketSessionConfig |
setMaxHandshakeFrameLength(int maxHandshakeFrameLength)
Sets the maximum length of the decoded Web Socket handshake frames.
|
DefaultWebSocketSessionConfig |
setRequestOrigin(String requestOrigin)
Sets the value of the Origin header field in the client Web Socket handshake
request.
|
DefaultWebSocketSessionConfig |
setSupportedExtensions(IExtension... extensions)
Sets the supported extensions for both the server and client
Web Socket sessions.
|
DefaultWebSocketSessionConfig |
setSupportedSubProtocols(String... subProtocols)
Sets the names of supported subprotocols for both the server and client
Web Socket sessions.
|
void |
switchDecoders(ICodecPipeline pipeline,
boolean allowExtensions)
Called when the decoders in the codec pipeline should be switched after
finishing of the Web Socket handshake.
|
void |
switchEncoders(ICodecPipeline pipeline,
boolean allowExtensions)
Called when the encoders in the codec pipeline should be switched after
finishing of the Web Socket handshake.
|
addSSLEngineBuilder, alwaysNotifiedBeingInPipeline, createSSLEngine, createSSLEngine, getDatagramServerSessionNoReopenPeriod, getEndingAction, getEngineHandshakeTimeout, getMaxInBufferCapacity, getMaxSSLApplicationBufferSizeRatio, getMaxSSLNetworkBufferSizeRatio, getMaxWriteSpinCount, getMinInBufferCapacity, getMinOutBufferCapacity, getSSLEngineBuilder, getThroughputCalculationInterval, ignorePossiblyIncompleteDatagrams, optimizeDataCopying, removeSSLEngineBuilder, setAlwaysNotifiedBeingInPipeline, setDatagramServerSessionNoReopenPeriod, setEndingAction, setEngineHandshakeTimeout, setIgnorePossiblyIncompleteDatagrams, setMaxInBufferCapacity, setMaxSSLApplicationBufferSizeRatio, setMaxSSLNetworkBufferSizeRatio, setMaxWriteSpinCount, setMinInBufferCapacity, setMinOutBufferCapacity, setOptimizeDataCopying, setThroughputCalculationInterval, setWaitForInboundCloseMessage, waitForInboundCloseMessage
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
alwaysNotifiedBeingInPipeline, createSSLEngine, createSSLEngine, getDatagramServerSessionNoReopenPeriod, getEndingAction, getEngineHandshakeTimeout, getMaxInBufferCapacity, getMaxSSLApplicationBufferSizeRatio, getMaxSSLNetworkBufferSizeRatio, getMaxWriteSpinCount, getMinInBufferCapacity, getMinOutBufferCapacity, getThroughputCalculationInterval, ignorePossiblyIncompleteDatagrams, optimizeDataCopying, waitForInboundCloseMessage
public DefaultWebSocketSessionConfig(URI requestUri)
requestUri
- request URI that will be used to set the Host header field
and the "Request-URI" of the GET methodpublic DefaultWebSocketSessionConfig()
public boolean isClientMode()
true
if this configuration is for a client session.public URI getRequestUri()
IWebSocketSessionConfig
It is not used for configuration of server sessions.
getRequestUri
in interface IWebSocketSessionConfig
public String getRequestOrigin()
It is not used for configuration of server sessions.
The default value is null
getRequestOrigin
in interface IWebSocketSessionConfig
null
if the Origin
field is not required in the request.public DefaultWebSocketSessionConfig setRequestOrigin(String requestOrigin)
requestOrigin
- the value of the Origin header field, or null
if
the Origin field is not required in the request.public String[] getSupportedSubProtocols()
The default value is null
getSupportedSubProtocols
in interface IWebSocketSessionConfig
public DefaultWebSocketSessionConfig setSupportedSubProtocols(String... subProtocols)
subProtocols
- the names of supported subprotocolspublic IExtension[] getSupportedExtensions()
The default value is null
getSupportedExtensions
in interface IWebSocketSessionConfig
public DefaultWebSocketSessionConfig setSupportedExtensions(IExtension... extensions)
extensions
- the supported extensionspublic boolean ignoreHostHeaderField()
The default value is false
ignoreHostHeaderField
in interface IWebSocketSessionConfig
true
to ignore missing the Host header fieldpublic DefaultWebSocketSessionConfig setIgnoreHostHeaderField(boolean ignoreHostHeaderField)
ignoreHostHeaderField
- true
to ignore missing the Host header
fieldpublic int getMaxHandshakeFrameLength()
The default value is 65536
getMaxHandshakeFrameLength
in interface IWebSocketSessionConfig
public DefaultWebSocketSessionConfig setMaxHandshakeFrameLength(int maxHandshakeFrameLength)
maxHandshakeFrameLength
- the maximum length of the decoded handshake
framespublic int getMaxFramePayloadLength()
The default value is 65536
getMaxFramePayloadLength
in interface IWebSocketSessionConfig
public DefaultWebSocketSessionConfig setMaxFramePayloadLength(int maxFramePayloadLength)
maxFramePayloadLength
- the maximum length of the payload in the decoded
framespublic boolean handleCloseFrame()
The default value is true
handleCloseFrame
in interface IWebSocketSessionConfig
true
if the close frames should be handled automaticallypublic DefaultWebSocketSessionConfig setHandleCloseFrame(boolean handleCloseFrame)
handleCloseFrame
- true
if the close frames should be handled
automaticallypublic ICodecExecutor createCodecExecutor()
DefaultSessionConfig
The default value is null
createCodecExecutor
in interface ISessionConfig
createCodecExecutor
in class DefaultSessionConfig
null
if decoding and encoding
is not required.public void switchEncoders(ICodecPipeline pipeline, boolean allowExtensions)
IWebSocketSessionConfig
switchEncoders
in interface IWebSocketSessionConfig
pipeline
- the codec pipeline to be changedallowExtensions
- informs that some extensions have been negotiated
during the Web Socket handshakepublic void switchDecoders(ICodecPipeline pipeline, boolean allowExtensions)
IWebSocketSessionConfig
switchDecoders
in interface IWebSocketSessionConfig
pipeline
- the codec pipeline to be changedallowExtensions
- informs that some extensions have been negotiated
during the Web Socket handshakepublic void customizeHeaders(HandshakeRequest request)
By default it does nothing
customizeHeaders
in interface IWebSocketSessionConfig
request
- the handshake request to be sentpublic void customizeHeaders(HandshakeResponse response)
By default it does nothing
customizeHeaders
in interface IWebSocketSessionConfig
response
- the handshake response to be sentpublic boolean acceptRequestUri(URI requestUri)
The requestUri
argument is built based on the Host header field
and the "Request-URI" of the GET method. If the Host header field is missed and the
IWebSocketSessionConfig.ignoreHostHeaderField()
returns true
the host-port part of the
URI will be set to the "null" string.
By default it always returns true
acceptRequestUri
in interface IWebSocketSessionConfig
requestUri
- the request URI in the received Web Socket handshake
requesttrue
if the request URI should be acceptedCopyright © 2017–2022 SNF4J.ORG. All rights reserved.