Author: markt Date: Wed Dec 19 22:23:50 2012 New Revision: 1424175 URL: http://svn.apache.org/viewvc?rev=1424175&view=rev Log: If the client drops the connection, tell the server the connection is closed.
Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java?rev=1424175&r1=1424174&r2=1424175&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java (original) +++ tomcat/trunk/java/org/apache/tomcat/websocket/WsProtocolHandler.java Wed Dec 19 22:23:50 2012 @@ -16,6 +16,7 @@ */ package org.apache.tomcat.websocket; +import java.io.EOFException; import java.io.IOException; import javax.servlet.ReadListener; @@ -24,6 +25,8 @@ import javax.servlet.ServletOutputStream import javax.servlet.WriteListener; import javax.servlet.http.ProtocolHandler; import javax.servlet.http.WebConnection; +import javax.websocket.CloseReason; +import javax.websocket.CloseReason.CloseCodes; import javax.websocket.Endpoint; /** @@ -54,7 +57,7 @@ public class WsProtocolHandler implement throw new IllegalStateException(e); } WsFrame wsFrame = new WsFrame(sis, wsSession); - sis.setReadListener(new WsReadListener(this, wsFrame)); + sis.setReadListener(new WsReadListener(this, wsFrame, wsSession)); WsRemoteEndpoint wsRemoteEndpoint = new WsRemoteEndpoint(sos); wsSession.setRemote(wsRemoteEndpoint); sos.setWriteListener(new WsWriteListener(this, wsRemoteEndpoint)); @@ -87,12 +90,14 @@ public class WsProtocolHandler implement private final WsProtocolHandler wsProtocolHandler; private final WsFrame wsFrame; + private final WsSession wsSession; private WsReadListener(WsProtocolHandler wsProtocolHandler, - WsFrame wsFrame) { + WsFrame wsFrame, WsSession wsSession) { this.wsProtocolHandler = wsProtocolHandler; this.wsFrame = wsFrame; + this.wsSession = wsSession; } @@ -101,7 +106,16 @@ public class WsProtocolHandler implement try { wsFrame.onDataAvailable(); } catch (IOException e) { - onError(e); + if (e instanceof EOFException){ + try { + wsSession.close(new CloseReason( + CloseCodes.CLOSED_ABNORMALLY, e.getMessage())); + } catch (IOException e1) { + // TODO + } + } else { + onError(e); + } } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org