Author: markt
Date: Fri Jun 28 12:55:21 2013
New Revision: 1497756
URL: http://svn.apache.org/r1497756
Log:
Add some plumbing to make the HTTP session ID available to the WeBSocket
session. This will be required to implement WebSocket 1.0, section 7.2.
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1497756&r1=1497755&r2=1497756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Fri Jun 28
12:55:21 2013
@@ -69,6 +69,7 @@ public class WsSession implements Sessio
private final String subProtocol;
private final Map<String,String> pathParameters;
private final boolean secure;
+ private final String httpSessionId;
private final String id;
// Expected to handle message types of <String> only
@@ -100,8 +101,8 @@ public class WsSession implements Sessio
WsRemoteEndpointImplBase wsRemoteEndpoint,
WsWebSocketContainer wsWebSocketContainer,
URI requestUri, Map<String,List<String>> requestParameterMap,
- String queryString, Principal userPrincipal, String subProtocol,
- Map<String,String> pathParameters,
+ String queryString, Principal userPrincipal, String httpSessionId,
+ String subProtocol, Map<String,String> pathParameters,
boolean secure, EndpointConfig endpointConfig)
throws DeploymentException {
this.localEndpoint = localEndpoint;
@@ -127,6 +128,7 @@ public class WsSession implements Sessio
}
this.queryString = queryString;
this.userPrincipal = userPrincipal;
+ this.httpSessionId = httpSessionId;
if (subProtocol == null) {
this.subProtocol = "";
} else {
@@ -522,6 +524,11 @@ public class WsSession implements Sessio
}
+ protected String getHttpSessionId() {
+ return httpSessionId;
+ }
+
+
protected MessageHandler getTextMessageHandler() {
return textMessageHandler;
}
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java?rev=1497756&r1=1497755&r2=1497756&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsWebSocketContainer.java Fri
Jun 28 12:55:21 2013
@@ -330,7 +330,7 @@ public class WsWebSocketContainer
WsSession wsSession = new WsSession(endpoint, wsRemoteEndpointClient,
- this, null, null, null, null, subProtocol,
+ this, null, null, null, null, null, subProtocol,
Collections.EMPTY_MAP, false,
clientEndpointConfiguration);
endpoint.onOpen(wsSession, clientEndpointConfiguration);
Modified:
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java?rev=1497756&r1=1497755&r2=1497756&view=diff
==============================================================================
---
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/websocket/server/WsHttpUpgradeHandler.java
Fri Jun 28 12:55:21 2013
@@ -24,6 +24,7 @@ import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.WriteListener;
+import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpUpgradeHandler;
import javax.servlet.http.WebConnection;
import javax.websocket.CloseReason;
@@ -99,6 +100,12 @@ public class WsHttpUpgradeHandler implem
throw new IllegalStateException(e);
}
+ String httpSessionId = null;
+ Object session = handshakeRequest.getHttpSession();
+ if (session != null ) {
+ httpSessionId = ((HttpSession) session).getId();
+ }
+
// Need to call onOpen using the web application's class loader
// Create the frame using the application's class loader so it can pick
// up application specific config from the ServerContainerImpl
@@ -112,8 +119,8 @@ public class WsHttpUpgradeHandler implem
webSocketContainer, handshakeRequest.getRequestURI(),
handshakeRequest.getParameterMap(),
handshakeRequest.getQueryString(),
- handshakeRequest.getUserPrincipal(), subProtocol,
- pathParameters, secure, endpointConfig);
+ handshakeRequest.getUserPrincipal(), httpSessionId,
+ subProtocol, pathParameters, secure, endpointConfig);
WsFrameServer wsFrame = new WsFrameServer(
sis,
wsSession);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]