Package io.socket.engineio.server
Class EngineIoServerOptions
java.lang.Object
io.socket.engineio.server.EngineIoServerOptions
Options for
EngineIoServer-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]Specify that all origins are to be allowed for CORSstatic final String[]Specify that no origins are allowed for CORSstatic final EngineIoServerOptionsThe default options used by server.private String[]private booleanprivate booleanprivate booleanprivate intprivate longprivate longprivate ScheduledExecutorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]Gets the allowed CORS origins option.Gets theEngineIoServer.HandshakeInterceptorfor the server.Packet<?> Gets the initial packet option.intGets the max threadpool size for the ping timeout timers.longGets the ping interval option in milliseconds.longGets the ping timeout option in milliseconds.Gets the customScheduledExecutorServicefor the server to use or null to let the server create it's own executor.booleanGets the value of 'isCorsHandlingDisabled' option.booleanWhether sync polling transport is allowed or not.voidlock()Lock this options instance to prevent modifications.static EngineIoServerOptionsCreate a new instance ofEngineIoServerOptionsby copying default options.setAllowedCorsOrigins(String[] allowedCorsOrigins) Sets the allowed CORS origins option.setAllowSyncPolling(boolean allowSyncPolling) Sets whether sync polling transport is allowed or not.setCorsHandlingDisabled(boolean corsHandlingDisabled) Sets the 'isCorsHandlingDisabled' option.voidsetHandshakeInterceptor(EngineIoServer.HandshakeInterceptor handshakeInterceptor) Sets aEngineIoServer.HandshakeInterceptorfor the server.setInitialPacket(Packet<?> initialPacket) Sets the initial packet.setMaxTimeoutThreadPoolSize(int maxTimeoutThreadPoolSize) Sets the max threadpool size for the ping timeout timers.setPingInterval(long pingInterval) Sets the ping interval option.setPingTimeout(long pingTimeout) Sets the ping timeout option.voidsetScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) Sets a customScheduledExecutorServicefor the server to use.
-
Field Details
-
DEFAULT
The default options used by server. This instance is locked and cannot be modified. ping timeout: 5000 ping interval: 25000 allowed origins: * -
ALLOWED_CORS_ORIGIN_ALL
Specify that all origins are to be allowed for CORS -
ALLOWED_CORS_ORIGIN_NONE
Specify that no origins are allowed for CORS -
mIsLocked
private boolean mIsLocked -
mCorsHandlingDisabled
private boolean mCorsHandlingDisabled -
mAllowSyncPolling
private boolean mAllowSyncPolling -
mPingInterval
private long mPingInterval -
mPingTimeout
private long mPingTimeout -
mAllowedCorsOrigins
-
mInitialPacket
-
mMaxTimeoutThreadPoolSize
private int mMaxTimeoutThreadPoolSize -
mScheduledExecutorService
-
mHandshakeInterceptor
-
-
Constructor Details
-
EngineIoServerOptions
private EngineIoServerOptions()
-
-
Method Details
-
newFromDefault
Create a new instance ofEngineIoServerOptionsby copying default options.- Returns:
- New instance of
EngineIoServerOptionswith default options.
-
isCorsHandlingDisabled
public boolean isCorsHandlingDisabled()Gets the value of 'isCorsHandlingDisabled' option. -
setCorsHandlingDisabled
public EngineIoServerOptions setCorsHandlingDisabled(boolean corsHandlingDisabled) throws IllegalStateException Sets the 'isCorsHandlingDisabled' option.- Parameters:
corsHandlingDisabled- Boolean value for disabling CORS handling.- Returns:
- Instance for chaining.
- Throws:
IllegalStateException- If instance is locked.
-
isSyncPollingAllowed
public boolean isSyncPollingAllowed()Whether sync polling transport is allowed or not. WARNING: Sync polling can cause the client to flood the server with requests. -
setAllowSyncPolling
Sets whether sync polling transport is allowed or not. WARNING: Sync polling can cause the client to flood the server with requests. -
getPingInterval
public long getPingInterval()Gets the ping interval option in milliseconds. -
setPingInterval
Sets the ping interval option.- Parameters:
pingInterval- Ping interval in milliseconds.- Returns:
- Instance for chaining.
- Throws:
IllegalStateException- If instance is locked.
-
getPingTimeout
public long getPingTimeout()Gets the ping timeout option in milliseconds. -
setPingTimeout
Sets the ping timeout option.- Parameters:
pingTimeout- Ping timeout in milliseconds.- Returns:
- Instance for chaining.
- Throws:
IllegalStateException- If instance is locked.
-
getAllowedCorsOrigins
Gets the allowed CORS origins option. -
setAllowedCorsOrigins
public EngineIoServerOptions setAllowedCorsOrigins(String[] allowedCorsOrigins) throws IllegalStateException Sets the allowed CORS origins option.- Parameters:
allowedCorsOrigins- Array of strings containing allowed CORS origins.- Returns:
- Instance for chaining.
- Throws:
IllegalStateException- If instance is locked.
-
getInitialPacket
Gets the initial packet option. -
setInitialPacket
public EngineIoServerOptions setInitialPacket(Packet<?> initialPacket) throws IllegalStateException, IllegalArgumentException Sets the initial packet.- Parameters:
initialPacket- The initial packet to send on client connection.- Returns:
- Instance for chaining.
- Throws:
IllegalStateException- If instance is locked.IllegalArgumentException- If initialPacket.type is not message or data is null.
-
lock
public void lock()Lock this options instance to prevent modifications. -
getMaxTimeoutThreadPoolSize
public int getMaxTimeoutThreadPoolSize()Gets the max threadpool size for the ping timeout timers. -
setMaxTimeoutThreadPoolSize
public EngineIoServerOptions setMaxTimeoutThreadPoolSize(int maxTimeoutThreadPoolSize) throws IllegalStateException Sets the max threadpool size for the ping timeout timers.- Parameters:
maxTimeoutThreadPoolSize- Max threadpool size for handling ping timeouts.- Returns:
- Instance for chaining.
- Throws:
IllegalStateException- If instance is locked.
-
getScheduledExecutorService
Gets the customScheduledExecutorServicefor the server to use or null to let the server create it's own executor. -
setScheduledExecutorService
Sets a customScheduledExecutorServicefor the server to use. This might be a good option if the application using this library already has an executor service it manages and uses. NOTE: Caller is responsible for shutting down this executor.- Parameters:
scheduledExecutorService- CustomScheduledExecutorServiceto use for timed tasks.
-
getHandshakeInterceptor
Gets theEngineIoServer.HandshakeInterceptorfor the server.EngineIoServer.HandshakeInterceptorcan be used to allow or block handshake. -
setHandshakeInterceptor
Sets aEngineIoServer.HandshakeInterceptorfor the server.EngineIoServer.HandshakeInterceptorcan be used to allow or block handshake.- Parameters:
handshakeInterceptor- Interceptor object to set for the server or null to remove it.
-