tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1530184 - in /tomcat/tc7.0.x/trunk: ./ webapps/examples/WEB-INF/classes/websocket/snake/Snake.java
Date Tue, 08 Oct 2013 08:11:50 GMT
Author: markt
Date: Tue Oct  8 08:11:50 2013
New Revision: 1530184

URL: http://svn.apache.org/r1530184
Log:
If the browser crashes or a similar event occurs writing messages will start failing. Rather
than ignoring these failures, close the session.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java

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

Modified: tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java?rev=1530184&r1=1530183&r2=1530184&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java (original)
+++ tomcat/tc7.0.x/trunk/webapps/examples/WEB-INF/classes/websocket/snake/Snake.java Tue Oct
 8 08:11:50 2013
@@ -21,6 +21,8 @@ import java.util.ArrayDeque;
 import java.util.Collection;
 import java.util.Deque;
 
+import javax.websocket.CloseReason;
+import javax.websocket.CloseReason.CloseCodes;
 import javax.websocket.Session;
 
 public class Snake {
@@ -65,7 +67,13 @@ public class Snake {
         try {
             session.getBasicRemote().sendText(msg);
         } catch (IOException ioe) {
-            // Ignore
+            CloseReason cr =
+                    new CloseReason(CloseCodes.CLOSED_ABNORMALLY, ioe.getMessage());
+            try {
+                session.close(cr);
+            } catch (IOException ioe2) {
+                // Ignore
+            }
         }
     }
 



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


Mime
View raw message