Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 819F7D25E for ; Fri, 9 Nov 2012 20:32:26 +0000 (UTC) Received: (qmail 68593 invoked by uid 500); 9 Nov 2012 20:32:25 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 68524 invoked by uid 500); 9 Nov 2012 20:32:25 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 68514 invoked by uid 99); 9 Nov 2012 20:32:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2012 20:32:25 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2012 20:32:23 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 76B182388A4A for ; Fri, 9 Nov 2012 20:32:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1407619 - /tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java Date: Fri, 09 Nov 2012 20:32:02 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121109203202.76B182388A4A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: markt Date: Fri Nov 9 20:32:01 2012 New Revision: 1407619 URL: http://svn.apache.org/viewvc?rev=1407619&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/trunk/java/org/apache/catalina/websocket/WsOutbound.java Modified: tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java?rev=1407619&r1=1407618&r2=1407619&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java (original) +++ tomcat/trunk/java/org/apache/catalina/websocket/WsOutbound.java Fri Nov 9 20:32:01 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 { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org