tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1351010 - in /tomcat/trunk/webapps/examples/websocket: chat.html echo.html snake.html
Date Sat, 16 Jun 2012 21:36:20 GMT
Author: markt
Date: Sat Jun 16 21:36:19 2012
New Revision: 1351010

URL: http://svn.apache.org/viewvc?rev=1351010&view=rev
Log:
Fix the WebSocket examples so the work with secure as well as non-secure connections.

Modified:
    tomcat/trunk/webapps/examples/websocket/chat.html
    tomcat/trunk/webapps/examples/websocket/echo.html
    tomcat/trunk/webapps/examples/websocket/snake.html

Modified: tomcat/trunk/webapps/examples/websocket/chat.html
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/chat.html?rev=1351010&r1=1351009&r2=1351010&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/websocket/chat.html (original)
+++ tomcat/trunk/webapps/examples/websocket/chat.html Sat Jun 16 21:36:19 2012
@@ -77,7 +77,11 @@
         });
 
         Chat.initialize = function() {
-            Chat.connect('ws://' + window.location.host + '/examples/websocket/chat');
+            if (window.location.protocol == 'http:') {
+                Chat.connect('ws://' + window.location.host + '/examples/websocket/chat');
+            } else {
+            	Chat.connect('wss://' + window.location.host + '/examples/websocket/chat');
+            }
         };
 
         Chat.sendMessage = (function() {

Modified: tomcat/trunk/webapps/examples/websocket/echo.html
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/echo.html?rev=1351010&r1=1351009&r2=1351010&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/websocket/echo.html (original)
+++ tomcat/trunk/webapps/examples/websocket/echo.html Sat Jun 16 21:36:19 2012
@@ -104,7 +104,11 @@
         }
 
         function updateTarget(target) {
-            document.getElementById('target').value = 'ws://' + window.location.host + target;
+        	if (window.location.protocol == 'http:') {
+        	    document.getElementById('target').value = 'ws://' + window.location.host + target;
+        	} else {
+        		document.getElementById('target').value = 'wss://' + window.location.host + target;
+        	}
         }
 
         function log(message) {

Modified: tomcat/trunk/webapps/examples/websocket/snake.html
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/snake.html?rev=1351010&r1=1351009&r2=1351010&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/websocket/snake.html (original)
+++ tomcat/trunk/webapps/examples/websocket/snake.html Sat Jun 16 21:36:19 2012
@@ -109,7 +109,11 @@
                     }
                 }
             }, false);
-            Game.connect('ws://' + window.location.host + '/examples/websocket/snake');
+            if (window.location.protocol == 'http:') {
+                Game.connect('ws://' + window.location.host + '/examples/websocket/snake');
+            } else {
+            	Game.connect('wss://' + window.location.host + '/examples/websocket/snake');
+            }
         };
 
         Game.setDirection  = function(direction) {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message