Class StreamingHttpProtocol
- java.lang.Object
-
- org.atmosphere.websocket.protocol.StreamingHttpProtocol
-
- All Implemented Interfaces:
AtmosphereConfigAware,WebSocketProtocol,WebSocketProtocolStream
public class StreamingHttpProtocol extends java.lang.Object implements WebSocketProtocolStream
Like theAsynchronousProcessorclass, this class is responsible for dispatching WebSocket stream to the properWebSocketimplementation by wrapping the Websocket message's bytes within anHttpServletRequest. The content-type is defined usingApplicationConfig.WEBSOCKET_CONTENT_TYPEproperty The method is defined usingApplicationConfig.WEBSOCKET_METHODproperty- Author:
- Jeanfrancois Arcand
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringcontentTypeprotected java.lang.Stringdelimiterprotected booleandestroyableprotected java.lang.StringmethodTypeprotected static java.lang.StringTEXT
-
Constructor Summary
Constructors Constructor Description StreamingHttpProtocol()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(AtmosphereConfig config)Configure an AtmosphereFramework object.java.util.List<AtmosphereRequest>onBinaryStream(WebSocket webSocket, java.io.InputStream stream)Parse the WebSocket stream, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology.voidonClose(WebSocket webSocket)Invoked when a WebSocket is closedvoidonError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)Invoked when an error occurs.java.util.List<AtmosphereRequest>onMessage(WebSocket webSocket, byte[] data, int offset, int length)Parse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology.java.util.List<AtmosphereRequest>onMessage(WebSocket webSocket, java.lang.String data)Parse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology.voidonOpen(WebSocket webSocket)Invoked when a WebSocket is openedjava.util.List<AtmosphereRequest>onTextStream(WebSocket webSocket, java.io.Reader r)Parse the WebSocket stream, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology.
-
-
-
Field Detail
-
TEXT
protected static final java.lang.String TEXT
- See Also:
- Constant Field Values
-
contentType
protected java.lang.String contentType
-
methodType
protected java.lang.String methodType
-
delimiter
protected java.lang.String delimiter
-
destroyable
protected boolean destroyable
-
-
Method Detail
-
configure
public void configure(AtmosphereConfig config)
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Parameters:
config-AtmosphereConfig
-
onTextStream
public java.util.List<AtmosphereRequest> onTextStream(WebSocket webSocket, java.io.Reader r)
Description copied from interface:WebSocketProtocolStreamParse the WebSocket stream, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology. InvokingAtmosphereFramework.asyncSupportwill delegate the request processing to theAtmosphereHandlerimplementation. Returning null means this implementation will handle itself the processing/dispatching of the WebSocket's request;
As an example, this is how Websocket messages are delegated to the Jersey runtime.- Specified by:
onTextStreamin interfaceWebSocketProtocolStream- Parameters:
webSocket- TheWebSocketconnectionr- aReader- Returns:
- a List of
AtmosphereRequest
-
onBinaryStream
public java.util.List<AtmosphereRequest> onBinaryStream(WebSocket webSocket, java.io.InputStream stream)
Description copied from interface:WebSocketProtocolStreamParse the WebSocket stream, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology. InvokingAtmosphereFramework.asyncSupportwill delegate the request processing to theAtmosphereHandlerimplementation. Returning null means this implementation will handle itself the processing/dispatching of the WebSocket's request;
As an example, this is how Websocket messages are delegated to the Jersey runtime.- Specified by:
onBinaryStreamin interfaceWebSocketProtocolStream- Parameters:
webSocket- TheWebSocketconnectionstream- aReader- Returns:
- a List of
AtmosphereRequest
-
onMessage
public java.util.List<AtmosphereRequest> onMessage(WebSocket webSocket, java.lang.String data)
Description copied from interface:WebSocketProtocolParse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology. InvokingAtmosphereFramework.asyncSupportwill delegate the request processing to theAtmosphereHandlerimplementation. Returning null means this implementation will handle itself the processing/dispatching of the WebSocket's request;
As an example, this is how Websocket messages are delegated to the Jersey runtime.- Specified by:
onMessagein interfaceWebSocketProtocol- Parameters:
webSocket- TheWebSocketconnectiondata- The Websocket message- Returns:
- a List of
AtmosphereRequest
-
onMessage
public java.util.List<AtmosphereRequest> onMessage(WebSocket webSocket, byte[] data, int offset, int length)
Description copied from interface:WebSocketProtocolParse the WebSocket message, and delegate the processing to theAtmosphereFramework.asyncSupportor to any existing technology. InvokingAtmosphereFramework.asyncSupportwill delegate the request processing to theAtmosphereHandlerimplementation. Returning null means this implementation will handle itself the processing/dispatching of the WebSocket's request;
As an example, this is how Websocket messages are delegated to the Jersey runtime.- Specified by:
onMessagein interfaceWebSocketProtocol- Parameters:
webSocket- TheWebSocketconnectionoffset- offset message indexlength- length of the message.- Returns:
- a List of
AtmosphereRequest
-
onOpen
public void onOpen(WebSocket webSocket)
Description copied from interface:WebSocketProtocolInvoked when a WebSocket is opened- Specified by:
onOpenin interfaceWebSocketProtocol- Parameters:
webSocket-WebSocket
-
onClose
public void onClose(WebSocket webSocket)
Description copied from interface:WebSocketProtocolInvoked when a WebSocket is closed- Specified by:
onClosein interfaceWebSocketProtocol- Parameters:
webSocket-WebSocket
-
onError
public void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)
Description copied from interface:WebSocketProtocolInvoked when an error occurs.- Specified by:
onErrorin interfaceWebSocketProtocol- Parameters:
webSocket-WebSockett- aWebSocketProcessor.WebSocketException
-
-