[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-commit] r3015 - jetty/trunk/jetty-websocket/src/main/java/org/eclipse/jetty/websocket

Author: gwilkins
Date: 2011-04-13 21:45:36 -0400 (Wed, 13 Apr 2011)
New Revision: 3015

Modified:
   jetty/trunk/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java
Log:
minor cleanup of variable names and ordering

Modified: jetty/trunk/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java
===================================================================
--- jetty/trunk/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java	2011-04-13 22:48:42 UTC (rev 3014)
+++ jetty/trunk/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketConnectionD06.java	2011-04-14 01:45:36 UTC (rev 3015)
@@ -493,7 +493,7 @@
 
         public void onFrame(byte flags, byte opcode, Buffer buffer)
         {
-            boolean more=(flags&0x8)==0;
+            boolean lastFrame = isLastFrame(flags); 
             
             synchronized(WebSocketConnectionD06.this)
             {
@@ -528,7 +528,7 @@
                                 if (_utf8.append(buffer.array(),buffer.getIndex(),buffer.length(),_connection.getMaxTextMessageSize()))
                                 {
                                     // If this is the last fragment, deliver the text buffer
-                                    if (more && _onTextMessage!=null)
+                                    if (lastFrame && _onTextMessage!=null)
                                     {
                                         _opcode=-1;
                                         String msg =_utf8.toString();
@@ -541,8 +541,7 @@
                                     _connection.close(WebSocketConnectionD06.CLOSE_LARGE,"Text message size > "+_connection.getMaxTextMessageSize()+" chars");
                                     _utf8.reset();
                                     _opcode=-1;
-                                }
-                                        
+                                }    
                             }
                             else if (_opcode>=0 && _connection.getMaxBinaryMessageSize()>=0)
                             {
@@ -557,7 +556,7 @@
                                     _aggregate.put(buffer);
 
                                     // If this is the last fragment, deliver
-                                    if (!more && _onBinaryMessage!=null)
+                                    if (lastFrame && _onBinaryMessage!=null)
                                     {
                                         try
                                         {
@@ -606,8 +605,13 @@
                         {
                             if(_onTextMessage!=null)
                             {
-                                if (more)
+                                if (lastFrame)
                                 {
+                                    // Deliver the message
+                                    _onTextMessage.onMessage(buffer.toString(StringUtil.__UTF8));
+                                }
+                                else 
+                                {
                                     if (_connection.getMaxTextMessageSize()>=0)
                                     {
                                         // If this is a text fragment, append to buffer
@@ -621,11 +625,6 @@
                                         }
                                     }
                                 }
-                                else 
-                                {
-                                    // Deliver the message
-                                    _onTextMessage.onMessage(buffer.toString(StringUtil.__UTF8));
-                                }
                             }
                             break;
                         }
@@ -634,8 +633,12 @@
                         {
                             if (_onBinaryMessage!=null)
                             {
-                                if (more)
+                                if (lastFrame)
                                 {
+                                    _onBinaryMessage.onMessage(array,buffer.getIndex(),buffer.length());
+                                }
+                                else   
+                                {
                                     if (_connection.getMaxBinaryMessageSize()>=0)
                                     {
                                         if (buffer.length()>_connection.getMaxBinaryMessageSize())
@@ -654,10 +657,6 @@
                                         }
                                     }
                                 }
-                                else
-                                {
-                                    _onBinaryMessage.onMessage(array,buffer.getIndex(),buffer.length());
-                                }
                             }
                         }      
                     }