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 |
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 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
|
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 |
isOpen()
Is the connection open.
|
boolean |
isReading()
Tests if the connection is actively reading.
|
void |
onClose() |
void |
onOpen() |
void |
outgoingFrame(Frame frame,
WriteCallback callback)
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<Void> |
write(byte[] buf,
int offset,
int len)
Generate a binary message, destined for Muxer
|
Future<Void> |
write(ByteBuffer buffer)
Generate a binary message, destined for Muxer
|
Future<Void> |
write(String message)
Generate a text message, destined for Muxer
|
public MuxChannel(long channelId, Muxer muxer)
public 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 IOState getIOState()
LogicalConnection
getIOState
in interface LogicalConnection
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 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 isOpen()
WebSocketConnection
isOpen
in interface WebSocketConnection
isOpen
in interface LogicalConnection
public boolean isReading()
LogicalConnection
isReading
in interface LogicalConnection
public void onClose()
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 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<Void> write(byte[] buf, int offset, int len)
write
in interface WebSocketConnection
public Future<Void> write(ByteBuffer buffer)
write
in interface WebSocketConnection
public Future<Void> write(String message)
write
in interface WebSocketConnection
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.