tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1422335 - in /tomcat/trunk/webapps/examples: WEB-INF/ WEB-INF/classes/websocket/echo/ websocket/
Date Sat, 15 Dec 2012 19:58:10 GMT
Author: markt
Date: Sat Dec 15 19:58:09 2012
New Revision: 1422335

URL: http://svn.apache.org/viewvc?rev=1422335&view=rev
Log:
Update the echo WebSocket example to use the new APIs.

Removed:
    tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoMessage.java
    tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoStream.java
Modified:
    tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
    tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java
    tomcat/trunk/webapps/examples/WEB-INF/web.xml
    tomcat/trunk/webapps/examples/websocket/echo.html

Modified: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java?rev=1422335&r1=1422334&r2=1422335&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java (original)
+++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoAnnotation.java Sat Dec
15 19:58:09 2012
@@ -18,20 +18,12 @@ package websocket.echo;
 
 import javax.websocket.WebSocketEndpoint;
 import javax.websocket.WebSocketMessage;
-import javax.websocket.WebSocketOpen;
-import javax.websocket.WebSocketPathParam;
 
-@WebSocketEndpoint("/websocket/echoAnnotation/{test}")
+@WebSocketEndpoint("/websocket/echoAnnotation")
 public class EchoAnnotation {
 
-    @WebSocketOpen
-    public void printOpen(@WebSocketPathParam("test") String test) {
-        System.out.println("EchoAnnotation.printOpen() with [" + test + "]");
-    }
-
     @WebSocketMessage
     public String printMessage(String msg) {
-        System.out.println("EchoAnnotation.printMessage() with [" + msg + "]");
         return msg;
     }
 }

Modified: tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java?rev=1422335&r1=1422334&r2=1422335&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java (original)
+++ tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/EchoEndpoint.java Sat Dec
15 19:58:09 2012
@@ -19,6 +19,7 @@ package websocket.echo;
 import java.io.IOException;
 
 import javax.websocket.Endpoint;
+import javax.websocket.MessageHandler;
 import javax.websocket.RemoteEndpoint;
 import javax.websocket.Session;
 
@@ -27,11 +28,11 @@ public class EchoEndpoint extends Endpoi
     @Override
     public void onOpen(Session session) {
         RemoteEndpoint remoteEndpoint = session.getRemote();
-        session.addMessageHandler(new EchoMessageHandler<>(remoteEndpoint));
+        session.addMessageHandler(new EchoMessageHandler(remoteEndpoint));
     }
 
-    private static class EchoMessageHandler<T>
-            implements javax.websocket.MessageHandler.Basic<String> {
+    private static class EchoMessageHandler
+            implements MessageHandler.Basic<String> {
 
         private final RemoteEndpoint remoteEndpoint;
 
@@ -42,7 +43,6 @@ public class EchoEndpoint extends Endpoi
         @Override
         public void onMessage(String message) {
             try {
-                System.out.println(message);
                 if (remoteEndpoint != null) {
                     remoteEndpoint.sendString(message);
                 }

Modified: tomcat/trunk/webapps/examples/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/web.xml?rev=1422335&r1=1422334&r2=1422335&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/WEB-INF/web.xml (original)
+++ tomcat/trunk/webapps/examples/WEB-INF/web.xml Sat Dec 15 19:58:09 2012
@@ -355,35 +355,9 @@
     </servlet-mapping>
 
     <!-- WebSocket Examples -->
-    <servlet>
-      <servlet-name>wsEchoStream</servlet-name>
-      <servlet-class>websocket.echo.EchoStream</servlet-class>
-    </servlet>
-    <servlet-mapping>
-      <servlet-name>wsEchoStream</servlet-name>
-      <url-pattern>/websocket/echoStream</url-pattern>
-    </servlet-mapping>
-    <servlet>
-      <servlet-name>wsEchoMessage</servlet-name>
-      <servlet-class>websocket.echo.EchoMessage</servlet-class>
-      <!-- Uncomment the following block to increase the default maximum
-           WebSocket buffer size from 2MB to 20MB which is required for the
-           Autobahn test suite to pass fully. -->
-      <!--
-      <init-param>
-        <param-name>byteBufferMaxSize</param-name>
-        <param-value>20971520</param-value>
-      </init-param>
-      <init-param>
-        <param-name>charBufferMaxSize</param-name>
-        <param-value>20971520</param-value>
-      </init-param>
-      -->
-    </servlet>
-    <servlet-mapping>
-      <servlet-name>wsEchoMessage</servlet-name>
-      <url-pattern>/websocket/echoMessage</url-pattern>
-    </servlet-mapping>
+    <listener>
+      <listener-class>websocket.echo.WsConfigListener</listener-class>
+    </listener>
     <servlet>
         <servlet-name>wsChat</servlet-name>
         <servlet-class>websocket.chat.ChatWebSocketServlet</servlet-class>

Modified: tomcat/trunk/webapps/examples/websocket/echo.html
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/echo.html?rev=1422335&r1=1422334&r2=1422335&view=diff
==============================================================================
--- tomcat/trunk/webapps/examples/websocket/echo.html (original)
+++ tomcat/trunk/webapps/examples/websocket/echo.html Sat Dec 15 19:58:09 2012
@@ -130,19 +130,13 @@
 <div>
     <div id="connect-container">
         <div>
-            <span>Connect using:</span>
-            <!-- echo example using streams on the server side -->
-            <input id="radio1" type="radio" name="group1" value="/examples/websocket/echoStream"
-                   onclick="updateTarget(this.value);"> <label for="radio1">streams</label>
-            <!-- echo example using messages on the server side -->
-            <input id="radio2" type="radio" name="group1" value="/examples/websocket/echoMessage"
-                   onclick="updateTarget(this.value);"> <label for="radio2">messages</label>
+            <span>Connect to service implemented using:</span>
             <!-- echo example using new programmatic API on the server side -->
-            <input id="radio3" type="radio" name="group1" value="/examples/websocket/echoProgrammatic"
-                   onclick="updateTarget(this.value);"> <label for="radio2">new
programmatic</label>
+            <input id="radio1" type="radio" name="group1" value="/examples/websocket/echoProgrammatic"
+                   onclick="updateTarget(this.value);"> <label for="radio1">programmatic
API</label>
             <!-- echo example using new annotation API on the server side -->
-            <input id="radio4" type="radio" name="group1" value="/examples/websocket/echoAnnotation/HelloWorld"
-                   onclick="updateTarget(this.value);"> <label for="radio2">new
annotation</label>
+            <input id="radio2" type="radio" name="group1" value="/examples/websocket/echoAnnotation"
+                   onclick="updateTarget(this.value);"> <label for="radio2">annotation
API</label>
         </div>
         <div>
             <input id="target" type="text" size="40" style="width: 350px"/>



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


Mime
View raw message