public abstract class AbstractWebSocketConnection extends AbstractConnection implements LogicalConnection, IOState.ConnectionStateListener
WebSocketConnection within the framework of the new Connection framework of jetty-io| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractWebSocketConnection.Stats |
Connection.ListenerEXECUTE_ONFILLABLE| Constructor and Description |
|---|
AbstractWebSocketConnection(EndPoint endp,
Executor executor,
Scheduler scheduler,
WebSocketPolicy policy,
ByteBufferPool bufferPool) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Performs a logical close of this connection.
|
void |
close(int statusCode,
String reason)
Send a websocket Close frame, with status code.
|
void |
complete(Callback callback) |
void |
disconnect()
Terminate the connection (no close frame sent)
|
void |
disconnect(boolean onlyOutput) |
protected void |
execute(Runnable task) |
void |
fillInterested()
Utility method to be called to register read interest.
|
void |
flush() |
ByteBufferPool |
getBufferPool() |
List<ExtensionConfig> |
getExtensions()
Get the list of extensions in use.
|
Generator |
getGenerator() |
IOState |
getIOState()
Get the IOState of the connection.
|
long |
getMaxIdleTimeout()
Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
|
Parser |
getParser() |
WebSocketPolicy |
getPolicy()
The policy that the connection is running under.
|
InetSocketAddress |
getRemoteAddress()
Get the remote Address in use for this connection.
|
Scheduler |
getScheduler() |
WebSocketSession |
getSession()
Get the Session for this connection
|
AbstractWebSocketConnection.Stats |
getStats() |
boolean |
isOpen()
Test if logical connection is still open
|
boolean |
isReading()
Tests if the connection is actively reading.
|
void |
onClose()
Physical connection disconnect.
|
void |
onConnectionStateChange(ConnectionState state) |
void |
onFillable()
Callback method invoked when the endpoint is ready to be read.
|
protected void |
onFillInterestedFailed(Throwable cause)
Callback method invoked when the endpoint failed to be ready to be read.
|
void |
onOpen()
Callback method invoked when this
Connection is opened. |
protected boolean |
onReadTimeout()
Callback method invoked when the endpoint failed to be ready to be read after a timeout
|
void |
outgoingFrame(Frame frame,
WriteCallback callback)
Frame from API, User, or Internal implementation destined for network.
|
void |
resume()
Resume a previously suspended connection.
|
void |
setExtensions(List<ExtensionConfig> extensions)
Get the list of extensions in use.
|
void |
setInputBufferSize(int inputBufferSize) |
void |
setMaxIdleTimeout(long ms)
Set the maximum number of milliseconds of idleness before the connection is closed/disconnected, (ie no frames are either sent or received)
|
void |
setSession(WebSocketSession session)
Set the session associated with this connection
|
SuspendToken |
suspend()
Suspend a the incoming read events on the connection.
|
String |
toString() |
addListener, block, getBytesIn, getBytesOut, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, getMessagesIn, getMessagesOutclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLocalAddress, setNextIncomingFramespublic AbstractWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
public void close()
ConnectionPerforms a logical close of this connection.
For simple connections, this may just mean to delegate the close to the associated
EndPoint but, for example, SSL connections should write the SSL close message
before closing the associated EndPoint.
close in interface AutoCloseableclose in interface Connectionclose in interface LogicalConnectionclose in class AbstractConnectionStatusCode,
LogicalConnection.close(int, String)public void close(int statusCode,
String reason)
LogicalConnectionAdvanced usage: results in an non-blocking async write, then connection close.
close in interface LogicalConnectionstatusCode - the status codereason - the (optional) reason. (can be null for no reason)StatusCodepublic void complete(Callback callback)
public void disconnect()
LogicalConnectiondisconnect in interface LogicalConnectionpublic void disconnect(boolean onlyOutput)
protected void execute(Runnable task)
public void fillInterested()
AbstractConnectionUtility method to be called to register read interest.
After a call to this method, AbstractConnection.onFillable() or AbstractConnection.onFillInterestedFailed(Throwable)
will be called back as appropriate.
fillInterested in class AbstractConnectionAbstractConnection.onFillable()public void flush()
public ByteBufferPool getBufferPool()
public List<ExtensionConfig> getExtensions()
This list is negotiated during the WebSocket Upgrade Request/Response handshake.
public Generator getGenerator()
public IOState getIOState()
LogicalConnectiongetIOState in interface LogicalConnectionpublic long getMaxIdleTimeout()
LogicalConnectiongetMaxIdleTimeout in interface LogicalConnectionpublic Parser getParser()
public WebSocketPolicy getPolicy()
LogicalConnectiongetPolicy in interface LogicalConnectionpublic InetSocketAddress getRemoteAddress()
LogicalConnectionNote: Non-physical connections, like during the Mux extensions, or during unit testing can result in a InetSocketAddress on port 0 and/or on localhost.
getRemoteAddress in interface LogicalConnectionpublic Scheduler getScheduler()
public WebSocketSession getSession()
LogicalConnectiongetSession in interface LogicalConnectionpublic AbstractWebSocketConnection.Stats getStats()
public boolean isOpen()
LogicalConnectionisOpen in interface LogicalConnectionpublic boolean isReading()
LogicalConnectionisReading in interface LogicalConnectionpublic void onClose()
Not related to WebSocket close handshake.
onClose in interface ConnectiononClose in class AbstractConnectionpublic void onConnectionStateChange(ConnectionState state)
onConnectionStateChange in interface IOState.ConnectionStateListenerpublic void onFillable()
AbstractConnectionCallback method invoked when the endpoint is ready to be read.
onFillable in class AbstractConnectionAbstractConnection.fillInterested()protected void onFillInterestedFailed(Throwable cause)
AbstractConnectionCallback method invoked when the endpoint failed to be ready to be read.
onFillInterestedFailed in class AbstractConnectioncause - the exception that caused the failurepublic void onOpen()
ConnectionCallback method invoked when this Connection is opened.
Creators of the connection implementation are responsible for calling this method.
onOpen in interface ConnectiononOpen in class AbstractConnectionprotected boolean onReadTimeout()
AbstractConnectionCallback method invoked when the endpoint failed to be ready to be read after a timeout
onReadTimeout in class AbstractConnectionpublic void outgoingFrame(Frame frame, WriteCallback callback)
outgoingFrame in interface OutgoingFramesframe - the frame to eventually write to the network.callback - the optional callback to use for success/failure of the network write operation. Can be null.public void resume()
SuspendTokenresume in interface SuspendTokenpublic void setExtensions(List<ExtensionConfig> extensions)
This list is negotiated during the WebSocket Upgrade Request/Response handshake.
extensions - the list of negotiated extensions in use.public void setInputBufferSize(int inputBufferSize)
setInputBufferSize in class AbstractConnectionpublic void setMaxIdleTimeout(long ms)
LogicalConnectionsetMaxIdleTimeout in interface LogicalConnectionms - the number of milliseconds of idle timeoutpublic void setSession(WebSocketSession session)
LogicalConnectionsetSession in interface LogicalConnectionsession - the sessionpublic SuspendToken suspend()
LogicalConnectionsuspend in interface LogicalConnectionpublic String toString()
toString in class AbstractConnectionCopyright © 1995-2015 Mort Bay Consulting. All Rights Reserved.