public abstract class WebSocket extends AtmosphereInterceptorWriter implements KeepOpenStreamAware
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
bb |
protected boolean |
binaryWrite |
protected CharBuffer |
cb |
static String |
CLEAN_CLOSE |
protected long |
lastWrite |
protected static org.slf4j.Logger |
logger |
static String |
NOT_SUPPORTED |
protected String |
uuid |
static String |
WEBSOCKET_ACCEPT_DONE |
static String |
WEBSOCKET_INITIATED |
static String |
WEBSOCKET_RESUME |
static String |
WEBSOCKET_SUSPEND |
filters, reversedFilters| Constructor and Description |
|---|
WebSocket(AtmosphereConfig config) |
| Modifier and Type | Method and Description |
|---|---|
Object |
attachment()
Return the attachment
|
WebSocket |
attachment(Object attachment)
Attach an object.
|
Map<String,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(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,
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
AtmosphereRequestImpl.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) |
String |
uuid() |
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,
String data)
Write a WebSocket message.
|
WebSocket |
write(byte[] b)
Use the underlying container's websocket to write the byte.
|
abstract WebSocket |
write(byte[] b,
int offset,
int length)
Use the underlying container's websocket to write the byte.
|
abstract WebSocket |
write(String s)
Use the underlying container's websocket to write the String.
|
WebSocket |
writeError(AtmosphereResponse r,
int errorCode,
String message)
Write an error code.
|
filters, interceptor, interceptor, invokeInterceptor, writeReadyprotected static final org.slf4j.Logger logger
public static final String WEBSOCKET_INITIATED
public static final String WEBSOCKET_SUSPEND
public static final String WEBSOCKET_RESUME
public static final String WEBSOCKET_ACCEPT_DONE
public static final String NOT_SUPPORTED
public static final String CLEAN_CLOSE
protected long lastWrite
protected boolean binaryWrite
protected ByteBuffer bb
protected CharBuffer cb
protected 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.public WebSocketHandler webSocketHandler()
public WebSocket resource(AtmosphereResource r)
AtmosphereResource to this WebSocketr - an AtmosphereResource to this WebSocketpublic WebSocket shiftAttributes()
AtmosphereRequestImpl.localAttributes() that where set when the websocket was opened.public Map<String,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 IOException
IOExceptionprotected byte[] transform(AtmosphereResponse response, byte[] b, int offset, int length) throws IOException
IOExceptionpublic WebSocket write(AtmosphereResponse r, String data) throws IOException
AsyncIOWriterwrite in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterdata - the WebSocket messageIOExceptionpublic WebSocket write(AtmosphereResponse r, byte[] data) throws IOException
AsyncIOWriterwrite in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterdata - the WebSocket messageIOExceptionpublic WebSocket write(AtmosphereResponse r, byte[] b, int offset, int length) throws IOException
AsyncIOWriterwrite in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterb - the WebSocket messageoffset - offset of the messagelength - length of the messageIOExceptionpublic WebSocket broadcast(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, String message) throws IOException
AsyncIOWriterwriteError in interface AsyncIOWriterwriteError in class AtmosphereInterceptorWritererrorCode - the error codeIOExceptionpublic WebSocket redirect(AtmosphereResponse r, String location) throws IOException
AsyncIOWriterredirect in interface AsyncIOWriterredirect in class AtmosphereInterceptorWriterIOExceptionpublic void close(AtmosphereResponse r) throws IOException
AsyncIOWriterclose in interface AsyncIOWriterclose in class AtmosphereInterceptorWriterIOExceptionpublic WebSocket flush(AtmosphereResponse r) throws IOException
AsyncIOWriterflush in interface AsyncIOWriterflush in class AtmosphereInterceptorWriterIOExceptionpublic abstract boolean isOpen()
public abstract WebSocket write(String s) throws IOException
s - a websocket String messageIOExceptionpublic abstract WebSocket write(byte[] b, int offset, int length) throws IOException
b - a websocket byte messageoffset - startlength - endIOExceptionpublic WebSocket write(byte[] b) throws IOException
b - a websocket byte messageIOExceptionpublic abstract void close()
public String uuid()
public static void notSupported(AtmosphereRequest request, AtmosphereResponse response) throws IOException
IOExceptionpublic WebSocket sendPing(byte[] payload)
payload - the bytes to sendpublic WebSocket sendPong(byte[] payload)
payload - the bytes to sendpublic WebSocket attachment(Object attachment)
public Object attachment()
Copyright © 2016. All rights reserved.