Merged many of the changes from the first attempt at an HTML5 Websocket implementation. Focused on the ones that didn't change the behavior of the web server.
This commit is contained in:
@@ -8,14 +8,62 @@ package com.foundation.web.interfaces;
|
||||
public interface IConnectionContext {
|
||||
/**
|
||||
* Gets the application data in the connection context's application data map by the given key.
|
||||
* This is connection specific data, not client specific data which should be stored in the session.
|
||||
* <br/>Warning: Websocket connections are multi threaded and as such, threads must synchronize before calling this method.
|
||||
* @return The application specific data element.
|
||||
*/
|
||||
public Object getApplicationData(String key);
|
||||
/**
|
||||
* Stores the application data in the connection context's application data map by the given key.
|
||||
* The application data may implement ISessionLifecycleAware if it should be called when the session is being released. This will only be called for a normal closing of the session. The session may still be restored at some time in the future.
|
||||
* The applicationData may implement ISessionLifecycleAware (ignore that this is not a session) if it should be called when the connection is being closed.
|
||||
* This is connection specific data, not client specific data which should be stored in the session.
|
||||
* <br/>Warning: Websocket connections are multi threaded and as such, threads must synchronize before calling this method.
|
||||
* @param key The key for the data. If the key is logically equal (equivalent) to an existing key, then the existing data will be replaced and returned.
|
||||
* @param applicationData The application specific data element.
|
||||
*/
|
||||
public void setApplicationData(String key, Object applicationData);
|
||||
/**
|
||||
* Upgrades the connection context to be a HTML5 websocket using the given optional protocol.
|
||||
* @param protocol The optional protocol which will be passed to the application when frames are received.
|
||||
* @param maxMessageLength The maximum number of bytes in an allowed websocket message (may be composed of multiple frames, does not include the frame header sizes).
|
||||
* @param websocketHandler The application provided handler of websocket messages.
|
||||
*/
|
||||
public void upgradeToWebsocket(String protocol, long maxMessageLength, WebsocketHandler websocketHandler);
|
||||
/**
|
||||
* Sends the message to the client if this connection has been upgraded to a websocket.
|
||||
* <br/>The call is ignored if this is not a websocket.
|
||||
* <br/>This is a thread safe call.
|
||||
* @param message The message. The message will be queued for sending and the call will return immediately.
|
||||
*/
|
||||
public void sendWebsocketMessage(byte[] message);
|
||||
/**
|
||||
* Sends the message to the client if this connection has been upgraded to a websocket.
|
||||
* <br/>The call is ignored if this is not a websocket.
|
||||
* <br/>This is a thread safe call.
|
||||
* @param message The message. The message will be queued for sending and the call will return immediately.
|
||||
*/
|
||||
public void sendWebsocketMessage(String message);
|
||||
/**
|
||||
* Sends the message to the client if this connection has been upgraded to a websocket.
|
||||
* <br/>The call is ignored if this is not a websocket.
|
||||
* <br/>This is a thread safe call.
|
||||
* @param message The message. The message will be queued for sending and the call will return immediately.
|
||||
*/
|
||||
public void sendWebsocketMessage(IStreamedWebsocketMessage message);
|
||||
/**
|
||||
* Sends the PING message to the client if this connection has been upgraded to a websocket.
|
||||
* <br/>The call is ignored if this is not a websocket.
|
||||
* <br/>This is a thread safe call.
|
||||
*/
|
||||
public void sendWebsocketPing();
|
||||
/**
|
||||
* Gets the protocol associated with this websocket.
|
||||
* @return The optional protocol associated with the connection context when it was upgraded to a websocket, or null if this context was never upgraded.
|
||||
*/
|
||||
public String getWebsocketProtocol();
|
||||
/**
|
||||
* Determines whether this connection context has been upgraded to a websocket.
|
||||
* @return Whether this is a websocket connection.
|
||||
*/
|
||||
public boolean isWebsocket();
|
||||
}//IConnectionContext//
|
||||
Reference in New Issue
Block a user