|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.atmosphere.cpr.AsyncIOWriterAdapter
org.atmosphere.cpr.AtmosphereInterceptorWriter
org.atmosphere.websocket.WebSocket
public abstract class WebSocket
Represent a portable WebSocket implementation which can be used to write message.
| Field Summary | |
|---|---|
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
|
| Fields inherited from class org.atmosphere.cpr.AtmosphereInterceptorWriter |
|---|
filters, reversedFilters |
| Constructor Summary | |
|---|---|
WebSocket(AtmosphereConfig config)
|
|
| Method Summary | |
|---|---|
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 |
protected byte[] |
transform(byte[] b,
int offset,
int length)
|
protected 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,
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(String s)
Use the underlying container's websocket to write the String. |
WebSocket |
writeError(AtmosphereResponse r,
int errorCode,
String message)
Write an error code. |
| Methods inherited from class org.atmosphere.cpr.AtmosphereInterceptorWriter |
|---|
filters, interceptor, invokeInterceptor, writeReady |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected 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
| Constructor Detail |
|---|
public WebSocket(AtmosphereConfig config)
| Method Detail |
|---|
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 WebSocket
r - an AtmosphereResource to this WebSocket
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
IOException
public WebSocket write(AtmosphereResponse r,
String data)
throws IOException
AsyncIOWriter
write in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterdata - the WebSocket message
IOException
public WebSocket write(AtmosphereResponse r,
byte[] data)
throws IOException
AsyncIOWriter
write in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterdata - the WebSocket message
IOException
public WebSocket write(AtmosphereResponse r,
byte[] b,
int offset,
int length)
throws IOException
AsyncIOWriter
write in interface AsyncIOWriterwrite in class AtmosphereInterceptorWriterb - the WebSocket messageoffset - offset of the messagelength - length of the message
IOExceptionpublic 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
AsyncIOWriter
writeError in interface AsyncIOWriterwriteError in class AtmosphereInterceptorWritererrorCode - the error code
IOException
public WebSocket redirect(AtmosphereResponse r,
String location)
throws IOException
AsyncIOWriter
redirect in interface AsyncIOWriterredirect in class AtmosphereInterceptorWriterIOException
public void close(AtmosphereResponse r)
throws IOException
AsyncIOWriter
close in interface AsyncIOWriterclose in class AtmosphereInterceptorWriterIOException
public WebSocket flush(AtmosphereResponse r)
throws IOException
AsyncIOWriter
flush in interface AsyncIOWriterflush in class AtmosphereInterceptorWriterIOExceptionpublic abstract boolean isOpen()
public abstract WebSocket write(String s)
throws IOException
s - a websocket String message
IOException
public abstract WebSocket write(byte[] b,
int offset,
int length)
throws IOException
b - a websocket byte messageoffset - startlength - end
IOExceptionpublic abstract void close()
protected String uuid()
public static void notSupported(AtmosphereRequest request,
AtmosphereResponse response)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||