org.atmosphere.websocket.protocol
Class StreamingHttpProtocol

java.lang.Object
  extended by org.atmosphere.websocket.protocol.StreamingHttpProtocol
All Implemented Interfaces:
WebSocketProtocol, WebSocketProtocolStream

public class StreamingHttpProtocol
extends Object
implements WebSocketProtocolStream

Like the 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

Author:
Jeanfrancois Arcand

Field Summary
protected  String contentType
           
protected  String delimiter
           
protected  boolean destroyable
           
protected  String methodType
           
protected static String TEXT
           
 
Constructor Summary
StreamingHttpProtocol()
           
 
Method Summary
 void configure(AtmosphereConfig config)
          Allow an implementation to query the AtmosphereConfig of init-param, etc.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT

protected static final String TEXT
See Also:
Constant Field Values

contentType

protected String contentType

methodType

protected String methodType

delimiter

protected String delimiter

destroyable

protected boolean destroyable
Constructor Detail

StreamingHttpProtocol

public StreamingHttpProtocol()
Method Detail

configure

public void configure(AtmosphereConfig config)
Description copied from interface: WebSocketProtocol
Allow an implementation to query the AtmosphereConfig of init-param, etc.

Specified by:
configure in interface WebSocketProtocol
Parameters:
config - AtmosphereConfig

onTextStream

public List<AtmosphereRequest> onTextStream(WebSocket webSocket,
                                            Reader r)
Description copied from interface: WebSocketProtocolStream
Parse the WebSocket stream, and delegate the processing to the 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;
As an example, this is how Websocket messages are delegated to the Jersey runtime.

Specified by:
onTextStream in interface WebSocketProtocolStream
Parameters:
webSocket - The WebSocket connection
r - a Reader
Returns:
a List of AtmosphereRequest

onBinaryStream

public List<AtmosphereRequest> onBinaryStream(WebSocket webSocket,
                                              InputStream stream)
Description copied from interface: WebSocketProtocolStream
Parse the WebSocket stream, and delegate the processing to the 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;
As an example, this is how Websocket messages are delegated to the Jersey runtime.

Specified by:
onBinaryStream in interface WebSocketProtocolStream
Parameters:
webSocket - The WebSocket connection
stream - a Reader
Returns:
a List of AtmosphereRequest

onMessage

public List<AtmosphereRequest> onMessage(WebSocket webSocket,
                                         String data)
Description copied from interface: WebSocketProtocol
Parse the WebSocket message, and delegate the processing to the 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;
As an example, this is how Websocket messages are delegated to the Jersey runtime.

Specified by:
onMessage in interface WebSocketProtocol
Parameters:
webSocket - The WebSocket connection
data - The Websocket message
Returns:
a List of AtmosphereRequest

onMessage

public List<AtmosphereRequest> onMessage(WebSocket webSocket,
                                         byte[] data,
                                         int offset,
                                         int length)
Description copied from interface: WebSocketProtocol
Parse the WebSocket message, and delegate the processing to the 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;
As an example, this is how Websocket messages are delegated to the Jersey runtime.

Specified by:
onMessage in interface WebSocketProtocol
Parameters:
webSocket - The WebSocket connection
offset - offset message index
length - length of the message.
Returns:
a List of AtmosphereRequest

onOpen

public void onOpen(WebSocket webSocket)
Description copied from interface: WebSocketProtocol
Invoked when a WebSocket is opened

Specified by:
onOpen in interface WebSocketProtocol
Parameters:
webSocket - WebSocket

onClose

public void onClose(WebSocket webSocket)
Description copied from interface: WebSocketProtocol
Invoked when a WebSocket is closed

Specified by:
onClose in interface WebSocketProtocol
Parameters:
webSocket - WebSocket

onError

public void onError(WebSocket webSocket,
                    WebSocketProcessor.WebSocketException t)
Description copied from interface: WebSocketProtocol
Invoked when an error occurs.

Specified by:
onError in interface WebSocketProtocol
Parameters:
webSocket - WebSocket
t - a WebSocketProcessor.WebSocketException


Copyright © 2014. All Rights Reserved.