Class SockJSHandlerOptions
java.lang.Object
io.vertx.ext.web.handler.sockjs.SockJSHandlerOptions
Options for configuring a SockJS handler
- Author:
- Tim Fox, Paulo Lopes
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default interval between heartbeat packets.static final booleanWhether aJSESSIONIDcookie should be inserted by default = true.static final StringThe default SockJS library URL to load in iframe when a transport does not support cross-domain communication natively.static final booleanWhether thewriteHandlershould be registered as local by default = true.static final intThe default maximum number of bytes an HTTP streaming request can send.static final booleanWhether awriteHandlershould be registered by default = false.static final longThe default delay before sending acloseevent to a silent client. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Constructor to create options from JSON.Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionaddDisabledTransport(String subProtocol) Add a transport (by name) to the set of disabled transports.longintlongbooleanbooleanbooleansetHeartbeatInterval(long heartbeatInterval) In order to keep proxies and load balancers from closing long running HTTP requests we need to pretend that the connection is active and send a heartbeat packet once in a while.setInsertJSESSIONID(boolean insertJSESSIONID) Whether to insert aJSESSIONIDcookie so load-balancers ensure requests for a specific SockJS session are always routed to the correct server.setLibraryURL(String libraryURL) Transports which don't support cross-domain communication natively use an iframe trick.setLocalWriteHandler(boolean localWriteHandler) Whether thewriteHandlershould be local only or cluster-wide.setMaxBytesStreaming(int maxBytesStreaming) Most streaming transports save responses on the client side and don't free memory used by delivered messages.Set the origin to be verified before a websocket upgrade happens.setRegisterWriteHandler(boolean registerWriteHandler) Whether awriteHandlershould be registered on theEventBus.setSessionTimeout(long sessionTimeout) Set the delay before the server sends acloseevent when a client receiving connection has not been seen for a while.
-
Field Details
-
DEFAULT_SESSION_TIMEOUT
public static final long DEFAULT_SESSION_TIMEOUTThe default delay before sending acloseevent to a silent client.- See Also:
-
DEFAULT_INSERT_JSESSIONID
public static final boolean DEFAULT_INSERT_JSESSIONIDWhether aJSESSIONIDcookie should be inserted by default = true.- See Also:
-
DEFAULT_HEARTBEAT_INTERVAL
public static final long DEFAULT_HEARTBEAT_INTERVALThe default interval between heartbeat packets.- See Also:
-
DEFAULT_MAX_BYTES_STREAMING
public static final int DEFAULT_MAX_BYTES_STREAMINGThe default maximum number of bytes an HTTP streaming request can send.- See Also:
-
DEFAULT_LIBRARY_URL
The default SockJS library URL to load in iframe when a transport does not support cross-domain communication natively.- See Also:
-
DEFAULT_REGISTER_WRITE_HANDLER
public static final boolean DEFAULT_REGISTER_WRITE_HANDLERWhether awriteHandlershould be registered by default = false.- See Also:
-
DEFAULT_LOCAL_WRITE_HANDLER
public static final boolean DEFAULT_LOCAL_WRITE_HANDLERWhether thewriteHandlershould be registered as local by default = true.- See Also:
-
-
Constructor Details
-
SockJSHandlerOptions
Copy constructor.- Parameters:
other- the options to copy
-
SockJSHandlerOptions
public SockJSHandlerOptions()Default constructor. -
SockJSHandlerOptions
Constructor to create options from JSON.- Parameters:
json- the JSON
-
-
Method Details
-
getSessionTimeout
public long getSessionTimeout()- Returns:
- the session timeout in milliseconds
-
setSessionTimeout
Set the delay before the server sends acloseevent when a client receiving connection has not been seen for a while.Defaults to 5 seconds.
- Parameters:
sessionTimeout- timeout in milliseconds- Returns:
- a reference to this, so the API can be used fluently
-
isInsertJSESSIONID
public boolean isInsertJSESSIONID()- Returns:
- true if a
JSESSIONIDcookie should be inserted, false otherwise
-
setInsertJSESSIONID
Whether to insert aJSESSIONIDcookie so load-balancers ensure requests for a specific SockJS session are always routed to the correct server.Defaults to
true.- Parameters:
insertJSESSIONID- true if aJSESSIONIDcookie should be inserted, false otherwise- Returns:
- a reference to this, so the API can be used fluently
-
getHeartbeatInterval
public long getHeartbeatInterval()- Returns:
- the hearbeat packet interval in milliseconds
-
setHeartbeatInterval
In order to keep proxies and load balancers from closing long running HTTP requests we need to pretend that the connection is active and send a heartbeat packet once in a while. This setting controls how often this is done.Defaults to 25 seconds.
- Parameters:
heartbeatInterval- interval in milliseconds- Returns:
- a reference to this, so the API can be used fluently
-
getMaxBytesStreaming
public int getMaxBytesStreaming()- Returns:
- maximum number of bytes an HTTP streaming request can send
-
setMaxBytesStreaming
Most streaming transports save responses on the client side and don't free memory used by delivered messages. Such transports need to be garbage-collected once in a while.This setting controls the maximum number of bytes that can be sent over a single HTTP streaming request before it will be closed. After that the client needs to open new request. Setting this value to one effectively disables streaming and will make streaming transports to behave like polling transports.
Defaults to 128K.
- Parameters:
maxBytesStreaming- maximum number of bytes an HTTP streaming request can send- Returns:
- a reference to this, so the API can be used fluently
-
getLibraryURL
- Returns:
- the SockJS library URL to load in iframe when a transport does not support cross-domain communication natively
-
setLibraryURL
Transports which don't support cross-domain communication natively use an iframe trick. A simple page is served from the SockJS server (using its foreign domain) and is placed in an invisible iframe.Code run from this iframe doesn't need to worry about cross-domain issues, as it's being run from domain local to the SockJS server. This iframe also does need to load SockJS javascript client library, and this option lets you specify its URL.
- Parameters:
libraryURL- the SockJS library URL- Returns:
- a reference to this, so the API can be used fluently
-
addDisabledTransport
Add a transport (by name) to the set of disabled transports.- Parameters:
subProtocol- the transport to disable- Returns:
- a reference to this, so the API can be used fluently
- See Also:
-
getDisabledTransports
-
isRegisterWriteHandler
public boolean isRegisterWriteHandler()- Returns:
- true if a
writeHandlershould be registered on theEventBus, false otherwise - See Also:
-
setRegisterWriteHandler
- Parameters:
registerWriteHandler- true to register awriteHandler- Returns:
- a reference to this, so the API can be used fluently
- See Also:
-
isLocalWriteHandler
public boolean isLocalWriteHandler()- Returns:
- true if the
writeHandleris local only, false otherwise - See Also:
-
setLocalWriteHandler
Whether thewriteHandlershould be local only or cluster-wide.Defaults to
true.- Parameters:
localWriteHandler- true to register locally, false otherwise- Returns:
- a reference to this, so the API can be used fluently
- See Also:
-
getOrigin
- Returns:
- the origin associated with this bridge
-
setOrigin
Set the origin to be verified before a websocket upgrade happens.Defaults to
null.- Parameters:
origin- web origin- Returns:
- a reference to this, so the API can be used fluently
-