Author: markt
Date: Tue Jan  8 21:10:07 2013
New Revision: 1430538

URL: http://svn.apache.org/viewvc?rev=1430538&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54381
Add support for receiving pong messages.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/StreamInbound.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1430508

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/StreamInbound.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/StreamInbound.java?rev=1430538&r1=1430537&r2=1430538&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/StreamInbound.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/StreamInbound.java 
Tue Jan  8 21:10:07 2013
@@ -138,7 +138,7 @@ public abstract class StreamInbound impl
                 } else if (opCode == Constants.OPCODE_PING) {
                     getWsOutbound().pong(frame.getPayLoad());
                 } else if (opCode == Constants.OPCODE_PONG) {
-                    // NO-OP
+                    doOnPong(frame.getPayLoad());
                 } else {
                     // Unknown OpCode
                     closeOutboundConnection(
@@ -218,6 +218,18 @@ public abstract class StreamInbound impl
         }
     }
 
+    private void doOnPong(ByteBuffer payload) {
+        // Need to call onPong using the web application's class loader
+        Thread t = Thread.currentThread();
+        ClassLoader cl = t.getContextClassLoader();
+        t.setContextClassLoader(applicationClassLoader);
+        try {
+            onPong(payload);
+        } finally {
+            t.setContextClassLoader(cl);
+        }
+    }
+    
     @Override
     public final void onUpgradeComplete() {
         // Need to call onOpen using the web application's class loader
@@ -253,6 +265,15 @@ public abstract class StreamInbound impl
         // NO-OP
     }
 
+    /**
+     * Intended to be overridden by sub-classes that wish to be notified
+     * when a pong is received. The default implementation is a NO-OP.
+     *
+     * @param payload   The payload included in the pong.
+     */
+    protected void onPong(ByteBuffer payload) {
+        // NO-OP
+    }
 
     /**
      * This method is called when there is a binary WebSocket message available

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1430538&r1=1430537&r2=1430538&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jan  8 21:10:07 2013
@@ -121,6 +121,10 @@
         Fix NPE in <code>WebappLoader.stopInternal</code> when stop is called
         after a failed start. (kkolinko)
       </fix>
+      <add>
+        <bug>54381</bug>: Add support for receiving WebSocket pong messages.
+        (markt)
+      </add>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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

Reply via email to