public abstract class AbstractWebSocketConnection extends AbstractConnection implements LogicalConnection
WebSocketConnection
within the framework of the new Connection
framework of jetty-ioConnection.Listener
Constructor and Description |
---|
AbstractWebSocketConnection(EndPoint endp,
Executor executor,
Scheduler scheduler,
WebSocketPolicy policy,
ByteBufferPool bufferPool) |
Modifier and Type | Method and Description |
---|---|
void |
assertInputOpen()
Perform a quick check that the connection input is open.
|
void |
assertOutputOpen()
Perform a quick check that the connection output is open.
|
void |
close()
Performs a logical close of this connection.
|
void |
close(int statusCode,
String reason)
Send a websocket Close frame, with status code.
|
<C> void |
complete(FrameBytes frameBytes) |
void |
disconnect()
Terminate the connection (no close frame sent)
|
void |
disconnect(boolean onlyOutput) |
void |
flush() |
ByteBufferPool |
getBufferPool() |
List<ExtensionConfig> |
getExtensions()
Get the list of extensions in use.
|
Generator |
getGenerator() |
Parser |
getParser() |
WebSocketPolicy |
getPolicy()
The policy that the connection is running under.
|
FrameQueue |
getQueue() |
InetSocketAddress |
getRemoteAddress()
Get the remote Address in use for this connection.
|
Scheduler |
getScheduler() |
WebSocketSession |
getSession()
Get the Session for this connection
|
ConnectionState |
getState()
Get the WebSocket connection State.
|
boolean |
isInputClosed()
Test if input is closed (as a result of receiving a close frame)
|
boolean |
isOpen()
Simple test to see if connection is open (and not closed)
|
boolean |
isOutputClosed()
Test if output is closed (as a result of sending a close frame)
|
boolean |
isReading()
Tests if the connection is actively reading.
|
void |
onClose()
Callback method invoked when this
Connection is closed. |
void |
onCloseHandshake(boolean incoming,
CloseInfo close)
A close handshake frame has been detected
|
void |
onFillable()
Callback method invoked when the endpoint is 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
|
Future<javax.net.websocket.SendResult> |
outgoingFrame(Frame frame) |
void |
resume()
Resume a previously suspended connection.
|
void |
setExtensions(List<ExtensionConfig> extensions)
Get the list of extensions in use.
|
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, fillInterested, getBytesIn, getBytesOut, getCreatedTimeStamp, getEndPoint, getExecutor, getInputBufferSize, getMessagesIn, getMessagesOut, onFillInterestedFailed, setInputBufferSize
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getLocalAddress, setNextIncomingFrames
public AbstractWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, WebSocketPolicy policy, ByteBufferPool bufferPool)
public void assertInputOpen() throws IOException
LogicalConnection
assertInputOpen
in interface LogicalConnection
IOException
- if the connection input is closedpublic void assertOutputOpen() throws IOException
LogicalConnection
assertOutputOpen
in interface LogicalConnection
IOException
- if the connection output is closedpublic void close()
Connection
Performs 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 AutoCloseable
close
in interface Connection
close
in interface LogicalConnection
close
in class AbstractConnection
StatusCode
,
LogicalConnection.close(int, String)
public void close(int statusCode, String reason)
LogicalConnection
Advanced usage: results in an non-blocking async write, then connection close.
close
in interface LogicalConnection
statusCode
- the status codereason
- the (optional) reason. (can be null for no reason)StatusCode
public <C> void complete(FrameBytes frameBytes)
public void disconnect()
LogicalConnection
disconnect
in interface LogicalConnection
public void disconnect(boolean onlyOutput)
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 Parser getParser()
public WebSocketPolicy getPolicy()
LogicalConnection
getPolicy
in interface LogicalConnection
public FrameQueue getQueue()
public InetSocketAddress getRemoteAddress()
LogicalConnection
Note: 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 LogicalConnection
public Scheduler getScheduler()
public WebSocketSession getSession()
LogicalConnection
getSession
in interface LogicalConnection
public ConnectionState getState()
LogicalConnection
getState
in interface LogicalConnection
public boolean isInputClosed()
LogicalConnection
isInputClosed
in interface LogicalConnection
public boolean isOpen()
LogicalConnection
isOpen
in interface LogicalConnection
public boolean isOutputClosed()
LogicalConnection
isOutputClosed
in interface LogicalConnection
public boolean isReading()
LogicalConnection
isReading
in interface LogicalConnection
public void onClose()
Connection
Callback method invoked when this Connection
is closed.
Creators of the connection implementation are responsible for calling this method.
onClose
in interface Connection
onClose
in class AbstractConnection
public void onCloseHandshake(boolean incoming, CloseInfo close)
LogicalConnection
onCloseHandshake
in interface LogicalConnection
incoming
- true if part of an incoming frame, false if part of an outgoing frame.close
- the close detailspublic void onFillable()
AbstractConnection
Callback method invoked when the endpoint is ready to be read.
onFillable
in class AbstractConnection
AbstractConnection.fillInterested()
public void onOpen()
Connection
Callback method invoked when this Connection
is opened.
Creators of the connection implementation are responsible for calling this method.
onOpen
in interface Connection
onOpen
in class AbstractConnection
protected boolean onReadTimeout()
AbstractConnection
Callback method invoked when the endpoint failed to be ready to be read after a timeout
onReadTimeout
in class AbstractConnection
public Future<javax.net.websocket.SendResult> outgoingFrame(Frame frame) throws IOException
outgoingFrame
in interface OutgoingFrames
IOException
public void resume()
SuspendToken
resume
in interface SuspendToken
public 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 setSession(WebSocketSession session)
LogicalConnection
setSession
in interface LogicalConnection
session
- the sessionpublic SuspendToken suspend()
LogicalConnection
suspend
in interface LogicalConnection
public String toString()
toString
in class AbstractConnection
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.