Author: remm
Date: Wed Dec 10 14:00:00 2014
New Revision: 1644412

URL: http://svn.apache.org/r1644412
Log:
Add some configuration, and default to sending those useful empty messages. 
Also remove explicit mention of the tests used.

Modified:
    tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java?rev=1644412&r1=1644411&r2=1644412&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/Constants.java Wed Dec 10 
14:00:00 2014
@@ -73,7 +73,7 @@ public class Constants {
 
     /* Configuration for extensions
      * Note: These options are primarily present to enable this implementation
-     *       to pass the WebSocket 1.1 TCK. They are expected to be removed 
once
+     *       to pass compliance tests. They are expected to be removed once
      *       the WebSocket API includes a mechanism for adding custom 
extensions
      *       and disabling built-in extensions.
      */
@@ -82,6 +82,10 @@ public class Constants {
     static final boolean ALLOW_UNSUPPORTED_EXTENSIONS =
             
Boolean.getBoolean("org.apache.tomcat.websocket.ALLOW_UNSUPPORTED_EXTENSIONS");
 
+    // Configuration for stream behavior
+    static final boolean STREAMS_DROP_EMPTY_MESSAGES =
+            
Boolean.getBoolean("org.apache.tomcat.websocket.STREAMS_DROP_EMPTY_MESSAGES");
+
     public static final boolean STRICT_SPEC_COMPLIANCE =
             Boolean.getBoolean(
                     "org.apache.tomcat.websocket.STRICT_SPEC_COMPLIANCE");

Modified: 
tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java?rev=1644412&r1=1644411&r2=1644412&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsRemoteEndpointImplBase.java 
Wed Dec 10 14:00:00 2014
@@ -939,7 +939,7 @@ public abstract class WsRemoteEndpointIm
 
             // Optimisation. If there is no data to flush then do not send an
             // empty message.
-            if (buffer.position() > 0) {
+            if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || buffer.position() > 
0) {
                 doWrite(false);
             }
         }
@@ -957,7 +957,7 @@ public abstract class WsRemoteEndpointIm
         }
 
         private void doWrite(boolean last) throws IOException {
-            if (used) {
+            if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || used) {
                 buffer.flip();
                 endpoint.startMessageBlock(Constants.OPCODE_BINARY, buffer, 
last);
             }
@@ -1016,7 +1016,7 @@ public abstract class WsRemoteEndpointIm
                         sm.getString("wsRemoteEndpoint.closedWriter"));
             }
 
-            if (buffer.position() > 0) {
+            if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || buffer.position() > 
0) {
                 doWrite(false);
             }
         }
@@ -1034,7 +1034,7 @@ public abstract class WsRemoteEndpointIm
         }
 
         private void doWrite(boolean last) throws IOException {
-            if (used) {
+            if (!Constants.STREAMS_DROP_EMPTY_MESSAGES || used) {
                 buffer.flip();
                 endpoint.sendPartialString(buffer, last);
                 buffer.clear();



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

Reply via email to