Package io.socket.engineio.server
Class EngineIoServerOptions
- java.lang.Object
-
- io.socket.engineio.server.EngineIoServerOptions
-
public final class EngineIoServerOptions extends java.lang.ObjectOptions forEngineIoServer
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]ALLOWED_CORS_ORIGIN_ALLSpecify that all origins are to be allowed for CORSstatic java.lang.String[]ALLOWED_CORS_ORIGIN_NONESpecify that no origins are allowed for CORSstatic EngineIoServerOptionsDEFAULTThe default options used by server.private java.lang.String[]mAllowedCorsOriginsprivate booleanmAllowSyncPollingprivate booleanmCorsHandlingDisabledprivate EngineIoServer.HandshakeInterceptormHandshakeInterceptorprivate Packet<java.lang.Object>mInitialPacketprivate booleanmIsLockedprivate intmMaxTimeoutThreadPoolSizeprivate longmPingIntervalprivate longmPingTimeoutprivate java.util.concurrent.ScheduledExecutorServicemScheduledExecutorService
-
Constructor Summary
Constructors Modifier Constructor Description privateEngineIoServerOptions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]getAllowedCorsOrigins()Gets the allowed CORS origins option.EngineIoServer.HandshakeInterceptorgetHandshakeInterceptor()Gets theEngineIoServer.HandshakeInterceptorfor the server.Packet<?>getInitialPacket()Gets the initial packet option.intgetMaxTimeoutThreadPoolSize()Gets the max threadpool size for the ping timeout timers.longgetPingInterval()Gets the ping interval option in milliseconds.longgetPingTimeout()Gets the ping timeout option in milliseconds.java.util.concurrent.ScheduledExecutorServicegetScheduledExecutorService()Gets the customScheduledExecutorServicefor the server to use or null to let the server create it's own executor.booleanisCorsHandlingDisabled()Gets the value of 'isCorsHandlingDisabled' option.booleanisSyncPollingAllowed()Whether sync polling transport is allowed or not.voidlock()Lock this options instance to prevent modifications.static EngineIoServerOptionsnewFromDefault()Create a new instance ofEngineIoServerOptionsby copying default options.EngineIoServerOptionssetAllowedCorsOrigins(java.lang.String[] allowedCorsOrigins)Sets the allowed CORS origins option.EngineIoServerOptionssetAllowSyncPolling(boolean allowSyncPolling)Sets whether sync polling transport is allowed or not.EngineIoServerOptionssetCorsHandlingDisabled(boolean corsHandlingDisabled)Sets the 'isCorsHandlingDisabled' option.voidsetHandshakeInterceptor(EngineIoServer.HandshakeInterceptor handshakeInterceptor)Sets aEngineIoServer.HandshakeInterceptorfor the server.EngineIoServerOptionssetInitialPacket(Packet<?> initialPacket)Sets the initial packet.EngineIoServerOptionssetMaxTimeoutThreadPoolSize(int maxTimeoutThreadPoolSize)Sets the max threadpool size for the ping timeout timers.EngineIoServerOptionssetPingInterval(long pingInterval)Sets the ping interval option.EngineIoServerOptionssetPingTimeout(long pingTimeout)Sets the ping timeout option.voidsetScheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)Sets a customScheduledExecutorServicefor the server to use.
-
-
-
Field Detail
-
DEFAULT
public static final EngineIoServerOptions 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
public static final java.lang.String[] ALLOWED_CORS_ORIGIN_ALL
Specify that all origins are to be allowed for CORS
-
ALLOWED_CORS_ORIGIN_NONE
public static final java.lang.String[] 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
private java.lang.String[] mAllowedCorsOrigins
-
mInitialPacket
private Packet<java.lang.Object> mInitialPacket
-
mMaxTimeoutThreadPoolSize
private int mMaxTimeoutThreadPoolSize
-
mScheduledExecutorService
private java.util.concurrent.ScheduledExecutorService mScheduledExecutorService
-
mHandshakeInterceptor
private EngineIoServer.HandshakeInterceptor mHandshakeInterceptor
-
-
Method Detail
-
newFromDefault
public static EngineIoServerOptions 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 java.lang.IllegalStateException
Sets the 'isCorsHandlingDisabled' option.- Parameters:
corsHandlingDisabled- Boolean value for disabling CORS handling.- Returns:
- Instance for chaining.
- Throws:
java.lang.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
public EngineIoServerOptions setAllowSyncPolling(boolean allowSyncPolling)
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
public EngineIoServerOptions setPingInterval(long pingInterval) throws java.lang.IllegalStateException
Sets the ping interval option.- Parameters:
pingInterval- Ping interval in milliseconds.- Returns:
- Instance for chaining.
- Throws:
java.lang.IllegalStateException- If instance is locked.
-
getPingTimeout
public long getPingTimeout()
Gets the ping timeout option in milliseconds.
-
setPingTimeout
public EngineIoServerOptions setPingTimeout(long pingTimeout) throws java.lang.IllegalStateException
Sets the ping timeout option.- Parameters:
pingTimeout- Ping timeout in milliseconds.- Returns:
- Instance for chaining.
- Throws:
java.lang.IllegalStateException- If instance is locked.
-
getAllowedCorsOrigins
public java.lang.String[] getAllowedCorsOrigins()
Gets the allowed CORS origins option.
-
setAllowedCorsOrigins
public EngineIoServerOptions setAllowedCorsOrigins(java.lang.String[] allowedCorsOrigins) throws java.lang.IllegalStateException
Sets the allowed CORS origins option.- Parameters:
allowedCorsOrigins- Array of strings containing allowed CORS origins.- Returns:
- Instance for chaining.
- Throws:
java.lang.IllegalStateException- If instance is locked.
-
getInitialPacket
public Packet<?> getInitialPacket()
Gets the initial packet option.
-
setInitialPacket
public EngineIoServerOptions setInitialPacket(Packet<?> initialPacket) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
Sets the initial packet.- Parameters:
initialPacket- The initial packet to send on client connection.- Returns:
- Instance for chaining.
- Throws:
java.lang.IllegalStateException- If instance is locked.java.lang.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 java.lang.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:
java.lang.IllegalStateException- If instance is locked.
-
getScheduledExecutorService
public java.util.concurrent.ScheduledExecutorService getScheduledExecutorService()
Gets the customScheduledExecutorServicefor the server to use or null to let the server create it's own executor.
-
setScheduledExecutorService
public void setScheduledExecutorService(java.util.concurrent.ScheduledExecutorService scheduledExecutorService)
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
public EngineIoServer.HandshakeInterceptor getHandshakeInterceptor()
Gets theEngineIoServer.HandshakeInterceptorfor the server.EngineIoServer.HandshakeInterceptorcan be used to allow or block handshake.
-
setHandshakeInterceptor
public void setHandshakeInterceptor(EngineIoServer.HandshakeInterceptor handshakeInterceptor)
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.
-
-