public abstract class WebSocket extends AtmosphereInterceptorWriter
| Modifier and Type | Field and Description |
|---|---|
protected java.nio.ByteBuffer |
bb |
protected boolean |
binaryWrite |
protected java.nio.CharBuffer |
cb |
static java.lang.String |
CLEAN_CLOSE |
protected long |
lastWrite |
protected static org.slf4j.Logger |
logger |
static java.lang.String |
NOT_SUPPORTED |
static java.lang.String |
WEBSOCKET_ACCEPT_DONE |
static java.lang.String |
WEBSOCKET_INITIATED |
static java.lang.String |
WEBSOCKET_RESUME |
static java.lang.String |
WEBSOCKET_SUSPEND |
filters| Constructor and Description |
|---|
WebSocket(AtmosphereConfig config) |
| Modifier and Type | Method and Description |
|---|---|
WebSocket |
binaryWrite(boolean binaryWrite)
Switch to binary write, or go back to text write.
|
WebSocket |
broadcast(java.lang.Object o)
Broadcast, using the
AtmosphereResource.getBroadcaster() the object to all
WebSocket associated with the Broadcaster. |
abstract void |
close()
Close the underlying WebSocket
|
void |
close(AtmosphereResponse r)
Close the underlying connection.
|
AtmosphereConfig |
config() |
WebSocket |
flush(AtmosphereResponse r)
Flush the buffered content.
|
abstract boolean |
isOpen()
Is the underlying WebSocket open.
|
long |
lastWriteTimeStampInMilliseconds()
The last time, in milliseconds, a write operation occurred.
|
static void |
notSupported(AtmosphereRequest request,
AtmosphereResponse response) |
WebSocket |
redirect(AtmosphereResponse r,
java.lang.String location)
Redirect a WebSocket request to another location.
|
AtmosphereResource |
resource()
Return the an
AtmosphereResource used by this WebSocket, or null if the WebSocket has been closed
before the WebSocket message has been processed. |
WebSocket |
resource(AtmosphereResource r)
Associate an
AtmosphereResource to this WebSocket |
protected java.lang.String |
retrieveUUID() |
protected byte[] |
transform(byte[] b,
int offset,
int length) |
protected WebSocketHandler |
webSocketHandler() |
protected WebSocket |
webSocketHandler(WebSocketHandler webSocketHandler) |
WebSocket |
write(AtmosphereResponse r,
byte[] data)
Write a WebSocket message.
|
WebSocket |
write(AtmosphereResponse r,
byte[] b,
int offset,
int length)
Write a WebSocket message.
|
WebSocket |
write(AtmosphereResponse r,
java.lang.String data)
Write a WebSocket message.
|
abstract WebSocket |
write(byte[] b,
int offset,
int length)
Use the underlying container's websocket to write the byte.
|
abstract WebSocket |
write(java.lang.String s)
Use the underlying container's websocket to write the String.
|
WebSocket |
writeError(AtmosphereResponse r,
int errorCode,
java.lang.String message)
Write an error code.
|
interceptor, invokeInterceptor, writeReadyprotected static final org.slf4j.Logger logger
public static final java.lang.String WEBSOCKET_INITIATED
public static final java.lang.String WEBSOCKET_SUSPEND
public static final java.lang.String WEBSOCKET_RESUME
public static final java.lang.String WEBSOCKET_ACCEPT_DONE
public static final java.lang.String NOT_SUPPORTED
public static final java.lang.String CLEAN_CLOSE
protected long lastWrite
protected boolean binaryWrite
protected java.nio.ByteBuffer bb
protected java.nio.CharBuffer cb
public WebSocket(AtmosphereConfig config)
public AtmosphereConfig config()
protected WebSocket webSocketHandler(WebSocketHandler webSocketHandler)
public WebSocket binaryWrite(boolean binaryWrite)
binaryWrite - true to switch to binary write.protected WebSocketHandler webSocketHandler()
public WebSocket resource(AtmosphereResource r)
AtmosphereResource to this WebSocketr - an AtmosphereResource to this WebSocketpublic AtmosphereResource resource()
AtmosphereResource used by this WebSocket, or null if the WebSocket has been closed
before the WebSocket message has been processed.AtmosphereResourcepublic long lastWriteTimeStampInMilliseconds()
protected byte[] transform(byte[] b,
int offset,
int length)
throws java.io.IOException
java.io.IOExceptionpublic WebSocket write(AtmosphereResponse r, java.lang.String data) throws java.io.IOException
AsyncIOWriterwrite in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterdata - the WebSocket messagejava.io.IOExceptionpublic WebSocket write(AtmosphereResponse r, byte[] data) throws java.io.IOException
AsyncIOWriterwrite in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterdata - the WebSocket messagejava.io.IOExceptionpublic WebSocket write(AtmosphereResponse r, byte[] b, int offset, int length) throws java.io.IOException
AsyncIOWriterwrite in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterb - the WebSocket messageoffset - offset of the messagelength - length of the messagejava.io.IOExceptionpublic WebSocket broadcast(java.lang.Object o)
AtmosphereResource.getBroadcaster() the object to all
WebSocket associated with the Broadcaster. This method does the same as
websocket.resource().getBroadcaster().broadcast(o).o - An object to broadcast to all WebSockets.public WebSocket writeError(AtmosphereResponse r, int errorCode, java.lang.String message) throws java.io.IOException
AsyncIOWriterwriteError in interface AsyncIOWriterwriteError in class AtmosphereInterceptorWritererrorCode - the error codejava.io.IOExceptionpublic WebSocket redirect(AtmosphereResponse r, java.lang.String location) throws java.io.IOException
AsyncIOWriterredirect in interface AsyncIOWriterredirect in class AtmosphereInterceptorWriterjava.io.IOExceptionpublic void close(AtmosphereResponse r) throws java.io.IOException
AsyncIOWriterclose in interface AsyncIOWriterclose in class AtmosphereInterceptorWriterjava.io.IOExceptionpublic WebSocket flush(AtmosphereResponse r) throws java.io.IOException
AsyncIOWriterflush in interface AsyncIOWriterflush in class AtmosphereInterceptorWriterjava.io.IOExceptionpublic abstract boolean isOpen()
public abstract WebSocket write(java.lang.String s) throws java.io.IOException
s - a websocket String messagejava.io.IOExceptionpublic abstract WebSocket write(byte[] b, int offset, int length) throws java.io.IOException
b - a websocket byte messageoffset - startlength - endjava.io.IOExceptionpublic abstract void close()
protected java.lang.String retrieveUUID()
public static void notSupported(AtmosphereRequest request, AtmosphereResponse response) throws java.io.IOException
java.io.IOExceptionCopyright © 2018. All Rights Reserved.