org.atmosphere.websocket
Interface WebSocketProtocol

All Superinterfaces:
AsyncProtocol
All Known Implementing Classes:
EchoProtocol, SimpleHttpProtocol

public interface WebSocketProtocol
extends AsyncProtocol

A WebSocket based protocol implementation. Implement this call to process WebSocket message and dispatch it to Atmosphere or any consumer of WebSocket message

Author:
Jeanfrancois Arcand

Method Summary
 void configure(AtmosphereServlet.AtmosphereConfig config)
          Allow an implementation to query the AtmosphereConfig of init-param, etc.
 void onClose(WebSocket webSocket)
          Invoked when a WebSocket is closed
 void onError(WebSocket webSocket, WebSocketProcessor.WebSocketException t)
          Invoked when an error occurs.
 AtmosphereRequest onMessage(WebSocket webSocket, byte[] data, int offset, int length)
          Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology.
 AtmosphereRequest onMessage(WebSocket webSocket, String data)
          Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology.
 void onOpen(WebSocket webSocket)
          Invoked when a WebSocket is opened
 
Methods inherited from interface org.atmosphere.cpr.AsyncProtocol
handleResponse, handleResponse, inspectResponse
 

Method Detail

configure

void configure(AtmosphereServlet.AtmosphereConfig config)
Allow an implementation to query the AtmosphereConfig of init-param, etc.

Parameters:
config - AtmosphereServlet.AtmosphereConfig

onMessage

AtmosphereRequest onMessage(WebSocket webSocket,
                            String data)
Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology. Invoking AtmosphereServlet.cometSupport 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.

Parameters:
webSocket - The WebSocket connection
data - The Websocket message

onMessage

AtmosphereRequest onMessage(WebSocket webSocket,
                            byte[] data,
                            int offset,
                            int length)
Parse the WebSocket message, and delegate the processing to the AtmosphereServlet.cometSupport or to any existing technology. Invoking AtmosphereServlet.cometSupport 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.

Parameters:
webSocket - The WebSocket connection
offset - offset message index
length - length of the message.

onOpen

void onOpen(WebSocket webSocket)
Invoked when a WebSocket is opened

Parameters:
webSocket - WebSocket

onClose

void onClose(WebSocket webSocket)
Invoked when a WebSocket is closed

Parameters:
webSocket - WebSocket

onError

void onError(WebSocket webSocket,
             WebSocketProcessor.WebSocketException t)
Invoked when an error occurs.

Parameters:
webSocket - WebSocket
t - a WebSocketProcessor.WebSocketException


Copyright © 2012. All Rights Reserved.