public abstract class WebSocket extends AtmosphereInterceptorWriter implements KeepOpenStreamAware
| 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 |
protected java.lang.String |
uuid |
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, reversedFilters| Constructor and Description |
|---|
WebSocket(AtmosphereConfig config) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
attachment()
Return the attachment
|
WebSocket |
attachment(java.lang.Object attachment)
Attach an object.
|
java.util.Map<java.lang.String,java.lang.Object> |
attributes()
Return the attribute that was set during the websocket's open operation.
|
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 |
WebSocket |
sendPing(byte[] payload)
Send a WebSocket Ping
|
WebSocket |
sendPong(byte[] payload)
Send a WebSocket Pong
|
WebSocket |
shiftAttributes()
Copy
AtmosphereRequest.localAttributes() that where set when the websocket was opened. |
protected byte[] |
transform(AtmosphereResponse response,
byte[] b,
int offset,
int length) |
protected byte[] |
transform(byte[] b,
int offset,
int length) |
java.lang.String |
uuid() |
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.
|
filters, interceptor, 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
protected java.lang.String uuid
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 WebSocket shiftAttributes()
AtmosphereRequest.localAttributes() that where set when the websocket was opened.public java.util.Map<java.lang.String,java.lang.Object> attributes()
public 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.IOExceptionprotected byte[] transform(AtmosphereResponse response, 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()
public java.lang.String uuid()
public static void notSupported(AtmosphereRequest request, AtmosphereResponse response) throws java.io.IOException
java.io.IOExceptionpublic WebSocket sendPing(byte[] payload)
payload - the bytes to sendpublic WebSocket sendPong(byte[] payload)
payload - the bytes to sendpublic WebSocket attachment(java.lang.Object attachment)
public java.lang.Object attachment()
Copyright © 2018. All Rights Reserved.