Class EngineIoServerOptions

java.lang.Object
io.socket.engineio.server.EngineIoServerOptions

public final class EngineIoServerOptions extends Object
Options for EngineIoServer
  • Field Details

    • 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 String[] ALLOWED_CORS_ORIGIN_ALL
      Specify that all origins are to be allowed for CORS
    • ALLOWED_CORS_ORIGIN_NONE

      public static final 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 String[] mAllowedCorsOrigins
    • mInitialPacket

      private Packet<Object> mInitialPacket
    • mMaxTimeoutThreadPoolSize

      private int mMaxTimeoutThreadPoolSize
    • mScheduledExecutorService

      private ScheduledExecutorService mScheduledExecutorService
    • mHandshakeInterceptor

      private EngineIoServer.HandshakeInterceptor mHandshakeInterceptor
  • Constructor Details

    • EngineIoServerOptions

      private EngineIoServerOptions()
  • Method Details

    • newFromDefault

      public static EngineIoServerOptions newFromDefault()
      Create a new instance of EngineIoServerOptions by copying default options.
      Returns:
      New instance of EngineIoServerOptions with 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

      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 IllegalStateException
      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

      public EngineIoServerOptions setPingTimeout(long pingTimeout) throws IllegalStateException
      Sets the ping timeout option.
      Parameters:
      pingTimeout - Ping timeout in milliseconds.
      Returns:
      Instance for chaining.
      Throws:
      IllegalStateException - If instance is locked.
    • getAllowedCorsOrigins

      public String[] 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

      public Packet<?> 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

      public ScheduledExecutorService getScheduledExecutorService()
      Gets the custom ScheduledExecutorService for the server to use or null to let the server create it's own executor.
    • setScheduledExecutorService

      public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)
      Sets a custom ScheduledExecutorService for 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 - Custom ScheduledExecutorService to use for timed tasks.
    • getHandshakeInterceptor

      public EngineIoServer.HandshakeInterceptor getHandshakeInterceptor()
      Gets the EngineIoServer.HandshakeInterceptor for the server. EngineIoServer.HandshakeInterceptor can be used to allow or block handshake.
    • setHandshakeInterceptor

      public void setHandshakeInterceptor(EngineIoServer.HandshakeInterceptor handshakeInterceptor)
      Sets a EngineIoServer.HandshakeInterceptor for the server. EngineIoServer.HandshakeInterceptor can be used to allow or block handshake.
      Parameters:
      handshakeInterceptor - Interceptor object to set for the server or null to remove it.