public class MuxChannel extends Object implements WebSocketConnection, LogicalConnection, IncomingFrames, SuspendToken
Constructor and Description |
---|
MuxChannel(long channelId,
Muxer muxer) |
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()
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() |
InetSocketAddress |
getLocalAddress()
Get the address of the local side.
|
WebSocketPolicy |
getPolicy()
Access the (now read-only)
WebSocketPolicy in use for this connection. |
InetSocketAddress |
getRemoteAddress()
Get the address of the remote side.
|
URI |
getRequestURI()
Get the Request URI
|
WebSocketSession |
getSession()
Get the Session for this connection
|
ConnectionState |
getState()
Get the WebSocket connection State.
|
String |
getSubProtocol()
Get the SubProtocol in use for this connection.
|
void |
incomingError(WebSocketException e)
Incoming exceptions from Muxer.
|
void |
incomingFrame(Frame frame)
Incoming frames from Muxer
|
boolean |
isActive() |
boolean |
isInputClosed()
Test if input is closed (as a result of receiving a close frame)
|
boolean |
isOpen()
Is the connection open.
|
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() |
void |
onCloseHandshake(boolean incoming,
CloseInfo close)
A close handshake frame has been detected
|
void |
onOpen() |
Future<javax.net.websocket.SendResult> |
outgoingFrame(Frame frame)
Frames destined for the Muxer
|
void |
ping(ByteBuffer buf)
Ping frame destined for the Muxer
|
void |
resume()
Resume a previously suspended connection.
|
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.
|
Future<javax.net.websocket.SendResult> |
write(byte[] buf,
int offset,
int len)
Generate a binary message, destined for Muxer
|
Future<javax.net.websocket.SendResult> |
write(ByteBuffer buffer)
Generate a binary message, destined for Muxer
|
Future<javax.net.websocket.SendResult> |
write(String message)
Generate a text message, destined for Muxer
|
public MuxChannel(long channelId, Muxer muxer)
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()
WebSocketConnection
Basic usage: results in an non-blocking async write, then connection close.
close
in interface WebSocketConnection
close
in interface LogicalConnection
StatusCode
,
WebSocketConnection.close(int, String)
public void close(int statusCode, String reason)
WebSocketConnection
Advanced usage: results in an non-blocking async write, then connection close.
close
in interface WebSocketConnection
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 InetSocketAddress getLocalAddress()
WebSocketConnection
getLocalAddress
in interface WebSocketConnection
getLocalAddress
in interface LogicalConnection
public WebSocketPolicy getPolicy()
WebSocketConnection
WebSocketPolicy
in use for this connection.getPolicy
in interface WebSocketConnection
getPolicy
in interface LogicalConnection
public InetSocketAddress getRemoteAddress()
WebSocketConnection
getRemoteAddress
in interface WebSocketConnection
getRemoteAddress
in interface LogicalConnection
public URI getRequestURI()
WebSocketConnection
getRequestURI
in interface WebSocketConnection
public WebSocketSession getSession()
LogicalConnection
getSession
in interface LogicalConnection
public ConnectionState getState()
LogicalConnection
getState
in interface LogicalConnection
public String getSubProtocol()
WebSocketConnection
getSubProtocol
in interface WebSocketConnection
public void incomingError(WebSocketException e)
incomingError
in interface IncomingFrames
public void incomingFrame(Frame frame)
incomingFrame
in interface IncomingFrames
public boolean isActive()
public boolean isInputClosed()
LogicalConnection
isInputClosed
in interface LogicalConnection
public boolean isOpen()
WebSocketConnection
isOpen
in interface WebSocketConnection
isOpen
in interface LogicalConnection
public boolean isOutputClosed()
LogicalConnection
isOutputClosed
in interface LogicalConnection
public boolean isReading()
LogicalConnection
isReading
in interface LogicalConnection
public void onClose()
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 onOpen()
public Future<javax.net.websocket.SendResult> outgoingFrame(Frame frame) throws IOException
outgoingFrame
in interface OutgoingFrames
IOException
public void ping(ByteBuffer buf) throws IOException
ping
in interface WebSocketConnection
IOException
public void resume()
SuspendToken
resume
in interface SuspendToken
public 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()
WebSocketConnection
suspend
in interface WebSocketConnection
suspend
in interface LogicalConnection
public Future<javax.net.websocket.SendResult> write(byte[] buf, int offset, int len) throws IOException
write
in interface WebSocketConnection
IOException
public Future<javax.net.websocket.SendResult> write(ByteBuffer buffer) throws IOException
write
in interface WebSocketConnection
IOException
public Future<javax.net.websocket.SendResult> write(String message) throws IOException
write
in interface WebSocketConnection
IOException
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.