Class AbstractWebSocketTransport
- java.lang.Object
-
- org.cometd.common.AbstractTransport
-
- org.cometd.client.transport.ClientTransport
-
- org.cometd.client.transport.HttpClientTransport
-
- org.cometd.client.websocket.common.AbstractWebSocketTransport
-
- All Implemented Interfaces:
Transport
,MessageClientTransport
- Direct Known Subclasses:
JettyWebSocketTransport
,OkHttpWebSocketTransport
,WebSocketTransport
public abstract class AbstractWebSocketTransport extends HttpClientTransport implements MessageClientTransport
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractWebSocketTransport.Delegate
-
Nested classes/interfaces inherited from class org.cometd.client.transport.ClientTransport
ClientTransport.Factory, ClientTransport.FailureHandler, ClientTransport.FailureInfo
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONNECT_TIMEOUT_OPTION
protected static java.lang.String
COOKIE_HEADER
static java.lang.String
IDLE_TIMEOUT_OPTION
static int
MAX_CLOSE_REASON_LENGTH
static java.lang.String
NAME
static int
NORMAL_CLOSE_CODE
static java.lang.String
PERMESSAGE_DEFLATE_OPTION
static java.lang.String
PREFIX
static java.lang.String
PROTOCOL_OPTION
static java.lang.String
STICKY_RECONNECT_OPTION
-
Fields inherited from class org.cometd.client.transport.ClientTransport
JSON_CONTEXT_OPTION, MAX_MESSAGE_SIZE_OPTION, MAX_NETWORK_DELAY_OPTION, MAX_SEND_BAYEUX_MESSAGE_SIZE_OPTION, SCHEDULER_OPTION, URL_OPTION
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractWebSocketTransport(java.lang.String url, java.util.Map<java.lang.String,java.lang.Object> options, java.util.concurrent.ScheduledExecutorService scheduler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
abort(java.lang.Throwable failure)
Aborts this transport, usually by cancelling all pending Bayeux messages that require a response, such as/meta/connect
s, without waiting for a response.protected abstract AbstractWebSocketTransport.Delegate
connect(java.lang.String uri, TransportListener listener, java.util.List<Message.Mutable> messages)
long
getConnectTimeout()
protected AbstractWebSocketTransport.Delegate
getDelegate()
long
getIdleTimeout()
java.lang.String
getProtocol()
void
init()
boolean
isPerMessageDeflateEnabled()
boolean
isStickyReconnect()
protected void
locked(java.lang.Runnable block)
protected <T> T
locked(java.util.function.Supplier<T> block)
void
send(TransportListener listener, java.util.List<Message.Mutable> messages)
void
setMessageTransportListener(TransportListener listener)
void
setURL(java.lang.String url)
void
terminate()
Terminates this transport, usually by closing network connections opened directly by this transport.-
Methods inherited from class org.cometd.client.transport.HttpClientTransport
getCookies, getCookieStore, setCookieStore, storeCookies
-
Methods inherited from class org.cometd.client.transport.ClientTransport
accept, generateJSON, getJSONContextClient, getMaxNetworkDelay, getScheduler, getURL, initScheduler, parseMessages, setMaxNetworkDelay, shutdownScheduler
-
Methods inherited from class org.cometd.common.AbstractTransport
getName, getOption, getOption, getOption, getOption, getOption, getOptionNames, getOptionPrefix, setOption, setOptionPrefix
-
-
-
-
Field Detail
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
PROTOCOL_OPTION
public static final java.lang.String PROTOCOL_OPTION
- See Also:
- Constant Field Values
-
PERMESSAGE_DEFLATE_OPTION
public static final java.lang.String PERMESSAGE_DEFLATE_OPTION
- See Also:
- Constant Field Values
-
CONNECT_TIMEOUT_OPTION
public static final java.lang.String CONNECT_TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
IDLE_TIMEOUT_OPTION
public static final java.lang.String IDLE_TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
STICKY_RECONNECT_OPTION
public static final java.lang.String STICKY_RECONNECT_OPTION
- See Also:
- Constant Field Values
-
MAX_CLOSE_REASON_LENGTH
public static final int MAX_CLOSE_REASON_LENGTH
- See Also:
- Constant Field Values
-
NORMAL_CLOSE_CODE
public static final int NORMAL_CLOSE_CODE
- See Also:
- Constant Field Values
-
COOKIE_HEADER
protected static final java.lang.String COOKIE_HEADER
- See Also:
- Constant Field Values
-
-
Method Detail
-
setMessageTransportListener
public void setMessageTransportListener(TransportListener listener)
- Specified by:
setMessageTransportListener
in interfaceMessageClientTransport
- Parameters:
listener
- the listener that handles unsolicited messages from the server
-
setURL
public void setURL(java.lang.String url)
- Overrides:
setURL
in classClientTransport
-
init
public void init()
- Overrides:
init
in classClientTransport
-
locked
protected void locked(java.lang.Runnable block)
-
locked
protected <T> T locked(java.util.function.Supplier<T> block)
-
getProtocol
public java.lang.String getProtocol()
-
isPerMessageDeflateEnabled
public boolean isPerMessageDeflateEnabled()
-
getIdleTimeout
public long getIdleTimeout()
-
getConnectTimeout
public long getConnectTimeout()
-
isStickyReconnect
public boolean isStickyReconnect()
-
abort
public void abort(java.lang.Throwable failure)
Description copied from class:ClientTransport
Aborts this transport, usually by cancelling all pending Bayeux messages that require a response, such as/meta/connect
s, without waiting for a response.- Specified by:
abort
in classClientTransport
- Parameters:
failure
- the cause of the abort- See Also:
BayeuxClient.abort()
-
terminate
public void terminate()
Description copied from class:ClientTransport
Terminates this transport, usually by closing network connections opened directly by this transport.- Overrides:
terminate
in classClientTransport
- See Also:
ClientSession.disconnect()
-
getDelegate
protected AbstractWebSocketTransport.Delegate getDelegate()
-
send
public void send(TransportListener listener, java.util.List<Message.Mutable> messages)
- Specified by:
send
in classClientTransport
-
connect
protected abstract AbstractWebSocketTransport.Delegate connect(java.lang.String uri, TransportListener listener, java.util.List<Message.Mutable> messages)
-
-