public class MuxChannel extends Object implements LogicalConnection, IncomingFrames, SuspendToken, IOState.ConnectionStateListener
Constructor and Description |
---|
MuxChannel(long channelId,
Muxer muxer) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Send a websocket Close frame, without a status code or reason.
|
void |
close(int statusCode,
String reason)
Send a websocket Close frame, with status code.
|
void |
disconnect()
Terminate the connection (no close frame sent)
|
long |
getChannelId() |
IOState |
getIOState()
Get the IOState of the connection.
|
InetSocketAddress |
getLocalAddress()
Get the local
InetSocketAddress in use for this 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)
|
WebSocketPolicy |
getPolicy()
The policy that the connection is running under.
|
InetSocketAddress |
getRemoteAddress()
Get the remote Address in use for this connection.
|
WebSocketSession |
getSession()
Get the Session for this connection
|
void |
incomingError(WebSocketException e)
Incoming exceptions from Muxer.
|
void |
incomingFrame(Frame frame)
Incoming frames from Muxer
|
boolean |
isActive() |
boolean |
isOpen()
Test if logical connection is still open
|
boolean |
isReading()
Tests if the connection is actively reading.
|
void |
onClose() |
void |
onConnectionStateChange(ConnectionState state) |
void |
onOpen() |
void |
outgoingFrame(Frame frame,
WriteCallback callback)
Frames destined for the Muxer
|
void |
resume()
Resume a previously suspended connection.
|
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 |
setNextIncomingFrames(IncomingFrames incoming)
Set where the connection should send the incoming frames to.
|
void |
setSession(WebSocketSession session)
Set the session associated with this connection
|
void |
setSubProtocol(String subProtocol) |
SuspendToken |
suspend()
Suspend a the incoming read events on the connection.
|
public MuxChannel(long channelId, Muxer muxer)
public void close()
LogicalConnection
Basic usage: results in an non-blocking async write, then connection close.
close
in interface LogicalConnection
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 void disconnect()
LogicalConnection
disconnect
in interface LogicalConnection
public long getChannelId()
public IOState getIOState()
LogicalConnection
getIOState
in interface LogicalConnection
public InetSocketAddress getLocalAddress()
LogicalConnection
InetSocketAddress
in use for this connection.
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.
getLocalAddress
in interface LogicalConnection
public long getMaxIdleTimeout()
LogicalConnection
getMaxIdleTimeout
in interface LogicalConnection
public WebSocketPolicy getPolicy()
LogicalConnection
getPolicy
in interface LogicalConnection
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 WebSocketSession getSession()
LogicalConnection
getSession
in interface LogicalConnection
public void incomingError(WebSocketException e)
incomingError
in interface IncomingFrames
public void incomingFrame(Frame frame)
incomingFrame
in interface IncomingFrames
public boolean isActive()
public boolean isOpen()
LogicalConnection
isOpen
in interface LogicalConnection
public boolean isReading()
LogicalConnection
isReading
in interface LogicalConnection
public void onClose()
public void onConnectionStateChange(ConnectionState state)
onConnectionStateChange
in interface IOState.ConnectionStateListener
public void onOpen()
public void outgoingFrame(Frame frame, WriteCallback callback)
outgoingFrame
in interface OutgoingFrames
frame
- 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()
SuspendToken
resume
in interface SuspendToken
public void setMaxIdleTimeout(long ms)
LogicalConnection
setMaxIdleTimeout
in interface LogicalConnection
ms
- the number of milliseconds of idle timeoutpublic void setNextIncomingFrames(IncomingFrames incoming)
LogicalConnection
Often this is from the Parser to the start of the extension stack, and eventually on to the session.
setNextIncomingFrames
in interface LogicalConnection
incoming
- the incoming frames handlerpublic void setSession(WebSocketSession session)
LogicalConnection
setSession
in interface LogicalConnection
session
- the sessionpublic void setSubProtocol(String subProtocol)
public SuspendToken suspend()
LogicalConnection
suspend
in interface LogicalConnection
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.