public class StreamingHttpProtocol extends Object implements WebSocketProtocolStream
AsynchronousProcessor
class, this class is responsible for dispatching WebSocket stream to the
proper WebSocket
implementation by wrapping the Websocket message's bytes within
an HttpServletRequest
.
The content-type is defined using ApplicationConfig.WEBSOCKET_CONTENT_TYPE
property
The method is defined using ApplicationConfig.WEBSOCKET_METHOD
property
Modifier and Type | Field and Description |
---|---|
protected String |
contentType |
protected String |
delimiter |
protected boolean |
destroyable |
protected String |
methodType |
protected static String |
TEXT |
Constructor and Description |
---|
StreamingHttpProtocol() |
Modifier and Type | Method and Description |
---|---|
void |
configure(AtmosphereConfig config)
Configure an AtmosphereFramework object.
|
List<AtmosphereRequest> |
onBinaryStream(WebSocket webSocket,
InputStream stream)
Parse the WebSocket stream, and delegate the processing to the
AtmosphereFramework.asyncSupport or
to any existing technology. |
void |
onClose(WebSocket webSocket)
Invoked when a WebSocket is closed
|
void |
onError(WebSocket webSocket,
WebSocketProcessor.WebSocketException t)
Invoked when an error occurs.
|
List<AtmosphereRequest> |
onMessage(WebSocket webSocket,
byte[] data,
int offset,
int length)
Parse the WebSocket message, and delegate the processing to the
AtmosphereFramework.asyncSupport or
to any existing technology. |
List<AtmosphereRequest> |
onMessage(WebSocket webSocket,
String data)
Parse the WebSocket message, and delegate the processing to the
AtmosphereFramework.asyncSupport or
to any existing technology. |
void |
onOpen(WebSocket webSocket)
Invoked when a WebSocket is opened
|
List<AtmosphereRequest> |
onTextStream(WebSocket webSocket,
Reader r)
Parse the WebSocket stream, and delegate the processing to the
AtmosphereFramework.asyncSupport or
to any existing technology. |
protected static final String TEXT
protected String contentType
protected String methodType
protected String delimiter
protected boolean destroyable
public void configure(AtmosphereConfig config)
AtmosphereConfigAware
configure
in interface AtmosphereConfigAware
config
- AtmosphereConfig
public List<AtmosphereRequest> onTextStream(WebSocket webSocket, Reader r)
WebSocketProtocolStream
AtmosphereFramework.asyncSupport
or
to any existing technology. Invoking AtmosphereFramework.asyncSupport
will delegate the request processing
to the AtmosphereHandler
implementation. Returning null means this implementation will
handle itself the processing/dispatching of the WebSocket's request;
onTextStream
in interface WebSocketProtocolStream
webSocket
- The WebSocket
connectionr
- a Reader
AtmosphereRequest
public List<AtmosphereRequest> onBinaryStream(WebSocket webSocket, InputStream stream)
WebSocketProtocolStream
AtmosphereFramework.asyncSupport
or
to any existing technology. Invoking AtmosphereFramework.asyncSupport
will delegate the request processing
to the AtmosphereHandler
implementation. Returning null means this implementation will
handle itself the processing/dispatching of the WebSocket's request;
onBinaryStream
in interface WebSocketProtocolStream
webSocket
- The WebSocket
connectionstream
- a Reader
AtmosphereRequest
public List<AtmosphereRequest> onMessage(WebSocket webSocket, String data)
WebSocketProtocol
AtmosphereFramework.asyncSupport
or
to any existing technology. Invoking AtmosphereFramework.asyncSupport
will delegate the request processing
to the AtmosphereHandler
implementation. Returning null means this implementation will
handle itself the processing/dispatching of the WebSocket's request;
onMessage
in interface WebSocketProtocol
webSocket
- The WebSocket
connectiondata
- The Websocket messageAtmosphereRequest
public List<AtmosphereRequest> onMessage(WebSocket webSocket, byte[] data, int offset, int length)
WebSocketProtocol
AtmosphereFramework.asyncSupport
or
to any existing technology. Invoking AtmosphereFramework.asyncSupport
will delegate the request processing
to the AtmosphereHandler
implementation. Returning null means this implementation will
handle itself the processing/dispatching of the WebSocket's request;
onMessage
in interface WebSocketProtocol
webSocket
- The WebSocket
connectionoffset
- offset message indexlength
- length of the message.AtmosphereRequest
public void onOpen(WebSocket webSocket)
WebSocketProtocol
onOpen
in interface WebSocketProtocol
webSocket
- WebSocket
public void onClose(WebSocket webSocket)
WebSocketProtocol
onClose
in interface WebSocketProtocol
webSocket
- WebSocket
public void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)
WebSocketProtocol
onError
in interface WebSocketProtocol
webSocket
- WebSocket
t
- a WebSocketProcessor.WebSocketException
Copyright © 2016. All rights reserved.