Class PusherOptions
- java.lang.Object
-
- com.pusher.client.PusherOptions
-
public class PusherOptions extends java.lang.Object
Configuration for aPusherinstance.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringLIB_VERSION
-
Constructor Summary
Constructors Constructor Description PusherOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.lang.StringbuildUrl(java.lang.String apiKey)Construct the URL for the WebSocket connection based on the options previous set on this object and the provided API keylonggetActivityTimeout()AuthorizergetAuthorizer()Deprecated.Please use getChannelauthorizerChannelAuthorizergetChannelAuthorizer()Gets the channel authorizer to be used when authorizing private and presence channels.intgetMaxReconnectGapInSeconds()intgetMaxReconnectionAttempts()longgetPongTimeout()java.net.ProxygetProxy()UserAuthenticatorgetUserAuthenticator()Gets the user authenticator to be used when signing in.booleanisEncrypted()Deprecated.Please use isUseTLSbooleanisUseTLS()PusherOptionssetActivityTimeout(long activityTimeout)The number of milliseconds of inactivity at which a "ping" will be triggered to check the connection.PusherOptionssetAuthorizer(Authorizer authorizer)Deprecated.Please use setChannelauthorizerPusherOptionssetChannelAuthorizer(ChannelAuthorizer channelAuthorizer)Sets the channel authorizer to be used when authorizing private and presence channels.PusherOptionssetCluster(java.lang.String cluster)PusherOptionssetEncrypted(boolean encrypted)Deprecated.Please use setUseTLSPusherOptionssetHost(java.lang.String host)The host to which connections will be made.PusherOptionssetMaxReconnectGapInSeconds(int maxReconnectGapInSeconds)The delay in two reconnection extends exponentially (1, 2, 4, ..PusherOptionssetMaxReconnectionAttempts(int maxReconnectionAttempts)Number of reconnect attempts when websocket connection failedPusherOptionssetPongTimeout(long pongTimeout)The number of milliseconds after a "ping" is sent that the client will wait to receive a "pong" response from the server before considering the connection broken and triggering a transition to the disconnected state.PusherOptionssetProxy(java.net.Proxy proxy)The default value is Proxy.NO_PROXY.PusherOptionssetUserAuthenticator(UserAuthenticator userAuthenticator)Sets the user authenticator to be used when signing in.PusherOptionssetUseTLS(boolean useTLS)Sets whether the connection to Pusher should be use TLS.PusherOptionssetWsPort(int wsPort)The port to which non TLS connections will be made.PusherOptionssetWssPort(int wssPort)The port to which encrypted connections will be made.
-
-
-
Field Detail
-
LIB_VERSION
public static final java.lang.String LIB_VERSION
-
-
Constructor Detail
-
PusherOptions
public PusherOptions()
-
-
Method Detail
-
isEncrypted
@Deprecated public boolean isEncrypted()
Deprecated.Please use isUseTLS
-
setEncrypted
@Deprecated public PusherOptions setEncrypted(boolean encrypted)
Deprecated.Please use setUseTLS
-
isUseTLS
public boolean isUseTLS()
- Returns:
- whether the connection to Pusher should use TLS
-
setUseTLS
public PusherOptions setUseTLS(boolean useTLS)
Sets whether the connection to Pusher should be use TLS.- Parameters:
useTLS- whether the connection should use TLS, by default this is true- Returns:
- this, for chaining
-
getUserAuthenticator
public UserAuthenticator getUserAuthenticator()
Gets the user authenticator to be used when signing in.- Returns:
- the user authenticator
-
setUserAuthenticator
public PusherOptions setUserAuthenticator(UserAuthenticator userAuthenticator)
Sets the user authenticator to be used when signing in.- Parameters:
userAuthenticator- The user authenticator to be used.- Returns:
- this, for chaining
-
getChannelAuthorizer
public ChannelAuthorizer getChannelAuthorizer()
Gets the channel authorizer to be used when authorizing private and presence channels.- Returns:
- the channel authorizer
-
setChannelAuthorizer
public PusherOptions setChannelAuthorizer(ChannelAuthorizer channelAuthorizer)
Sets the channel authorizer to be used when authorizing private and presence channels.- Parameters:
channelAuthorizer- The channel authorizer to be used.- Returns:
- this, for chaining
-
getAuthorizer
@Deprecated public Authorizer getAuthorizer()
Deprecated.Please use getChannelauthorizer
-
setAuthorizer
@Deprecated public PusherOptions setAuthorizer(Authorizer authorizer)
Deprecated.Please use setChannelauthorizer
-
setHost
public PusherOptions setHost(java.lang.String host)
The host to which connections will be made.Note that if you wish to connect to a standard Pusher cluster, the convenience method setCluster will set the host and ports correctly from a single argument.
- Parameters:
host- The host- Returns:
- this, for chaining
-
setWsPort
public PusherOptions setWsPort(int wsPort)
The port to which non TLS connections will be made.Note that if you wish to connect to a standard Pusher cluster, the convenience method setCluster will set the host and ports correctly from a single argument.
- Parameters:
wsPort- port number- Returns:
- this, for chaining
-
setWssPort
public PusherOptions setWssPort(int wssPort)
The port to which encrypted connections will be made.Note that if you wish to connect to a standard Pusher cluster, the convenience method setCluster will set the host and ports correctly from a single argument.
- Parameters:
wssPort- port number- Returns:
- this, for chaining
-
setCluster
public PusherOptions setCluster(java.lang.String cluster)
-
setActivityTimeout
public PusherOptions setActivityTimeout(long activityTimeout)
The number of milliseconds of inactivity at which a "ping" will be triggered to check the connection.The default value is 120,000 (2 minutes). On some connections, where intermediate hops between the application and Pusher are aggressively culling connections they consider to be idle, a lower value may help preserve the connection.
- Parameters:
activityTimeout- time to consider connection idle, in milliseconds- Returns:
- this, for chaining
-
getActivityTimeout
public long getActivityTimeout()
-
setPongTimeout
public PusherOptions setPongTimeout(long pongTimeout)
The number of milliseconds after a "ping" is sent that the client will wait to receive a "pong" response from the server before considering the connection broken and triggering a transition to the disconnected state.The default value is 30,000.
- Parameters:
pongTimeout- time to wait for pong response, in milliseconds- Returns:
- this, for chaining
-
setMaxReconnectionAttempts
public PusherOptions setMaxReconnectionAttempts(int maxReconnectionAttempts)
Number of reconnect attempts when websocket connection failed- Parameters:
maxReconnectionAttempts- number of max reconnection attempts, default =MAX_RECONNECTION_ATTEMPTS6- Returns:
- this, for chaining
-
setMaxReconnectGapInSeconds
public PusherOptions setMaxReconnectGapInSeconds(int maxReconnectGapInSeconds)
The delay in two reconnection extends exponentially (1, 2, 4, .. seconds) This property sets the maximum in between two reconnection attempts.- Parameters:
maxReconnectGapInSeconds- time in seconds of the maximum gab between two reconnection attempts, default =MAX_RECONNECT_GAP_IN_SECONDS30s- Returns:
- this, for chaining
-
getPongTimeout
public long getPongTimeout()
-
buildUrl
public java.lang.String buildUrl(java.lang.String apiKey)
Construct the URL for the WebSocket connection based on the options previous set on this object and the provided API key- Parameters:
apiKey- The API key- Returns:
- the WebSocket URL
-
setProxy
public PusherOptions setProxy(java.net.Proxy proxy)
The default value is Proxy.NO_PROXY.- Parameters:
proxy- Specify a proxy, e.g.options.setProxy( new Proxy( Proxy.Type.HTTP, new InetSocketAddress( "proxyaddress", 80 ) ) );- Returns:
- this, for chaining
-
getProxy
public java.net.Proxy getProxy()
- Returns:
- The proxy to be used when opening a websocket connection to Pusher.
-
getMaxReconnectionAttempts
public int getMaxReconnectionAttempts()
- Returns:
- the maximum reconnection attempts
-
getMaxReconnectGapInSeconds
public int getMaxReconnectGapInSeconds()
- Returns:
- the maximum reconnection gap in seconds
-
-