Author: markt Date: Fri Nov 9 20:34:06 2012 New Revision: 1407620 URL: http://svn.apache.org/viewvc?rev=1407620&view=rev Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54127 Add support for sending a WebSocket ping Patch provided by Sean Winterberger
Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1407619 Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java?rev=1407620&r1=1407619&r2=1407620&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/websocket/WsOutbound.java Fri Nov 9 20:34:06 2012 @@ -301,6 +301,29 @@ public class WsOutbound { * @throws IOException If an error occurs writing to the client */ public synchronized void pong(ByteBuffer data) throws IOException { + sendControlMessage(data, Constants.OPCODE_PONG); + } + + /** + * Send a ping message to the client + * + * @param data Optional message. + * + * @throws IOException If an error occurs writing to the client + */ + public synchronized void ping(ByteBuffer data) throws IOException { + sendControlMessage(data, Constants.OPCODE_PING); + } + + /** + * Generic function to send either a ping or a pong. + * + * @param data Optional message. + * @param opcode The byte to include as the opcode. + * + * @throws IOException If an error occurs writing to the client + */ + private synchronized void sendControlMessage(ByteBuffer data, byte opcode) throws IOException { if (closed) { throw new IOException(sm.getString("outbound.closed")); @@ -308,7 +331,7 @@ public class WsOutbound { doFlush(true); - upgradeOutbound.write(0x8A); + upgradeOutbound.write(0x80 | opcode); if (data == null) { upgradeOutbound.write(0); } else { 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=1407620&r1=1407619&r2=1407620&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Nov 9 20:34:06 2012 @@ -110,6 +110,10 @@ <bug>54096</bug>: In web.xml, <env-entry> should accept any type that has a constructor that takes a single String or char. (markt) </fix> + <add> + <bug>54127</bug>: Add support for sending a WebSocket Ping. Patch + provided by Sean Winterberger. (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