Class AbstractWebSocketTransport
- java.lang.Object
-
- org.cometd.common.AbstractTransport
-
- org.cometd.client.transport.ClientTransport
-
- org.cometd.client.transport.HttpClientTransport
-
- org.cometd.websocket.client.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 String
CONNECT_TIMEOUT_OPTION
protected static String
COOKIE_HEADER
static String
IDLE_TIMEOUT_OPTION
static int
MAX_CLOSE_REASON_LENGTH
static String
NAME
static int
NORMAL_CLOSE_CODE
static String
PREFIX
static String
PROTOCOL_OPTION
static String
STICKY_RECONNECT_OPTION
-
Fields inherited from class org.cometd.client.transport.ClientTransport
JSON_CONTEXT_OPTION, logger, MAX_MESSAGE_SIZE_OPTION, MAX_NETWORK_DELAY_OPTION, SCHEDULER_OPTION, URL_OPTION
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractWebSocketTransport(String url, Map<String,Object> options, ScheduledExecutorService scheduler)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
abort()
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(String uri, TransportListener listener, List<Message.Mutable> messages)
long
getConnectTimeout()
protected AbstractWebSocketTransport.Delegate
getDelegate()
long
getIdleTimeout()
String
getProtocol()
void
init()
boolean
isStickyReconnect()
protected void
locked(Runnable block)
protected <T> T
locked(Supplier<T> block)
void
send(TransportListener listener, List<Message.Mutable> messages)
void
setMessageTransportListener(TransportListener listener)
void
setURL(String url)
protected void
storeCookies(Map<String,List<String>> headers)
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, getMaxNetworkDelay, getURL, parseMessages, setMaxNetworkDelay
-
Methods inherited from class org.cometd.common.AbstractTransport
getName, getOption, getOption, getOption, getOption, getOption, getOptionNames, getOptionPrefix, setOption, setOptionPrefix
-
-
-
-
Field Detail
-
PREFIX
public static final String PREFIX
- See Also:
- Constant Field Values
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
PROTOCOL_OPTION
public static final String PROTOCOL_OPTION
- See Also:
- Constant Field Values
-
CONNECT_TIMEOUT_OPTION
public static final String CONNECT_TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
IDLE_TIMEOUT_OPTION
public static final String IDLE_TIMEOUT_OPTION
- See Also:
- Constant Field Values
-
STICKY_RECONNECT_OPTION
public static final 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 String COOKIE_HEADER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractWebSocketTransport
protected AbstractWebSocketTransport(String url, Map<String,Object> options, ScheduledExecutorService scheduler)
-
-
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(String url)
- Overrides:
setURL
in classClientTransport
-
init
public void init()
- Overrides:
init
in classClientTransport
-
locked
protected void locked(Runnable block)
-
locked
protected <T> T locked(Supplier<T> block)
-
getProtocol
public String getProtocol()
-
getIdleTimeout
public long getIdleTimeout()
-
getConnectTimeout
public long getConnectTimeout()
-
isStickyReconnect
public boolean isStickyReconnect()
-
abort
public void abort()
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
- 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, List<Message.Mutable> messages)
- Specified by:
send
in classClientTransport
-
connect
protected abstract AbstractWebSocketTransport.Delegate connect(String uri, TransportListener listener, List<Message.Mutable> messages)
-
-