Class WebSocketConnection
java.lang.Object
org.eclipse.jetty.io.AbstractConnection
org.eclipse.jetty.websocket.core.internal.WebSocketConnection
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Runnable,- Connection,- Connection.UpgradeTo,- Dumpable
public class WebSocketConnection
extends AbstractConnection
implements Connection.UpgradeTo, Dumpable, Runnable
Provides the implementation of 
Connection that is suitable for WebSocket- 
Nested Class SummaryNested classes/interfaces inherited from interface org.eclipse.jetty.io.ConnectionConnection.Listener, Connection.UpgradeFrom, Connection.UpgradeToNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.DumpableDumpable.DumpableContainer
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionWebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, RetainableByteBufferPool retainableByteBufferPool, WebSocketCoreSession coreSession) Create a WSConnection.WebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, RetainableByteBufferPool retainableByteBufferPool, WebSocketCoreSession coreSession, Random randomMask) Create a WSConnection.
- 
Method SummaryModifier and TypeMethodDescriptionvoidvoiddemand(long n) dump()voiddump(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.longlongDeprecated.longlongDeprecated.usegetRemoteSocketAddress()insteadbooleanbooleanbooleanbooleanvoidPhysical connection disconnect.voidCallback method invoked when the endpoint is ready to be read.protected voidonFrame(Parser.ParsedFrame frame) booleanCallback method invoked upon an idle timeout event.voidonOpen()Physical connection Open.protected booleanonReadTimeout(Throwable timeout) Event for no activity on connection (read or write)voidonUpgradeTo(ByteBuffer buffer) Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connectionvoidrun()protected voidsetInitialBuffer(ByteBuffer initialBuffer) Extra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connectionvoidsetInputBufferSize(int inputBufferSize) voidsetUseInputDirectByteBuffers(boolean useInputDirectByteBuffers) voidsetUseOutputDirectByteBuffers(boolean useOutputDirectByteBuffers) Methods inherited from class org.eclipse.jetty.io.AbstractConnectionaddEventListener, close, failedCallback, fillInterested, getCreatedTimeStamp, getEndPoint, getInputBufferSize, isFillInterested, onFillInterestedFailed, removeEventListener, toString, tryFillInterested
- 
Constructor Details- 
WebSocketConnectionpublic WebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, RetainableByteBufferPool retainableByteBufferPool, WebSocketCoreSession coreSession) Create a WSConnection.It is assumed that the WebSocket Upgrade Handshake has already completed successfully before creating this connection. 
- 
WebSocketConnectionpublic WebSocketConnection(EndPoint endp, Executor executor, Scheduler scheduler, ByteBufferPool bufferPool, RetainableByteBufferPool retainableByteBufferPool, WebSocketCoreSession coreSession, Random randomMask) Create a WSConnection.It is assumed that the WebSocket Upgrade Handshake has already completed successfully before creating this connection. - Parameters:
- endp- The endpoint ever which Websockot is sent/received
- executor- A thread executor to use for WS callbacks.
- scheduler- A scheduler to use for timeouts
- bufferPool- A pool of buffers to use.
- retainableByteBufferPool- A pool of retainable buffers to use.
- coreSession- The WC core session to which frames are delivered.
- randomMask- A Random used to mask frames. If null then SecureRandom will be created if needed.
 
 
- 
- 
Method Details- 
getExecutor- Overrides:
- getExecutorin class- AbstractConnection
 
- 
getBufferPool
- 
getGenerator
- 
getParser
- 
getLocalAddressDeprecated.usegetLocalSocketAddress()instead- Returns:
- the local InetSocketAddress
 
- 
getLocalSocketAddress
- 
getRemoteAddressDeprecated.usegetRemoteSocketAddress()instead- Returns:
- the remote InetSocketAddress
 
- 
getRemoteSocketAddress
- 
isUseInputDirectByteBufferspublic boolean isUseInputDirectByteBuffers()
- 
setUseInputDirectByteBufferspublic void setUseInputDirectByteBuffers(boolean useInputDirectByteBuffers) 
- 
isUseOutputDirectByteBufferspublic boolean isUseOutputDirectByteBuffers()
- 
setUseOutputDirectByteBufferspublic void setUseOutputDirectByteBuffers(boolean useOutputDirectByteBuffers) 
- 
onClosePhysical connection disconnect.Not related to WebSocket close handshake. - Specified by:
- onClosein interface- Connection
- Overrides:
- onClosein class- AbstractConnection
- Parameters:
- cause- The cause of the close or null for a normal close
 
- 
onIdleExpiredpublic boolean onIdleExpired()Description copied from interface:ConnectionCallback method invoked upon an idle timeout event. Implementations of this method may return true to indicate that the idle timeout handling should proceed normally, typically failing the EndPoint and causing it to be closed. When false is returned, the handling of the idle timeout event is halted immediately and the EndPoint left in the state it was before the idle timeout event. - Specified by:
- onIdleExpiredin interface- Connection
- Overrides:
- onIdleExpiredin class- AbstractConnection
- Returns:
- true to let the EndPoint handle the idle timeout, false to tell the EndPoint to halt the handling of the idle timeout.
 
- 
onReadTimeoutEvent for no activity on connection (read or write)- Overrides:
- onReadTimeoutin class- AbstractConnection
- Parameters:
- timeout- the cause of the read timeout
- Returns:
- true to signal that the endpoint must be closed, false to keep the endpoint open
 
- 
onFrame
- 
onFillablepublic void onFillable()Description copied from class:AbstractConnectionCallback method invoked when the endpoint is ready to be read. - Specified by:
- onFillablein class- AbstractConnection
- See Also:
 
- 
runpublic void run()
- 
demandpublic void demand(long n) 
- 
moreDemandpublic boolean moreDemand()
- 
meetDemandpublic boolean meetDemand()
- 
cancelDemandpublic void cancelDemand()
- 
setInitialBufferExtra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connection- Parameters:
- initialBuffer- the bytes of extra content encountered during upgrade
 
- 
onOpenpublic void onOpen()Physical connection Open.- Specified by:
- onOpenin interface- Connection
- Overrides:
- onOpenin class- AbstractConnection
 
- 
setInputBufferSizepublic void setInputBufferSize(int inputBufferSize) - Overrides:
- setInputBufferSizein class- AbstractConnection
 
- 
dump
- 
dumpDescription copied from interface:DumpableDump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.- Specified by:
- dumpin interface- Dumpable
- Parameters:
- out- The appendable to dump to
- indent- The indent to apply after any new lines.
- Throws:
- IOException- if unable to write to Appendable
 
- 
toConnectionString- Overrides:
- toConnectionStringin class- AbstractConnection
 
- 
onUpgradeToExtra bytes from the initial HTTP upgrade that need to be processed by the websocket parser before starting to read bytes from the connection- Specified by:
- onUpgradeToin interface- Connection.UpgradeTo
- Parameters:
- buffer- a non-null buffer of extra bytes
 
- 
getFrameFlusher
- 
getMessagesInpublic long getMessagesIn()- Specified by:
- getMessagesInin interface- Connection
- Overrides:
- getMessagesInin class- AbstractConnection
 
- 
getBytesInpublic long getBytesIn()- Specified by:
- getBytesInin interface- Connection
- Overrides:
- getBytesInin class- AbstractConnection
 
- 
getMessagesOutpublic long getMessagesOut()- Specified by:
- getMessagesOutin interface- Connection
- Overrides:
- getMessagesOutin class- AbstractConnection
 
- 
getBytesOutpublic long getBytesOut()- Specified by:
- getBytesOutin interface- Connection
- Overrides:
- getBytesOutin class- AbstractConnection
 
 
- 
getLocalSocketAddress()instead