316449 Websocket disconnect fix
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1996 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
0104b834b8
commit
331a750ce0
|
@ -1,3 +1,6 @@
|
|||
jetty-7.1.5-SNAPSHOT
|
||||
+ 316449 Websocket disconnect fix
|
||||
|
||||
jetty-7.1.4.v20100610
|
||||
+ 298551 SslSocketConnector does not need keystore stream
|
||||
+ 295715 AbstractSessionManager decoupled from Context
|
||||
|
|
|
@ -186,7 +186,6 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.security.NoSuchAlgorithmException;
|
|||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
|
@ -98,6 +99,8 @@ public class WebSocketGenerator
|
|||
|
||||
private synchronized void bufferPut(byte datum, long blockFor) throws IOException
|
||||
{
|
||||
if (_buffer==null)
|
||||
_buffer=_buffers.getDirectBuffer();
|
||||
_buffer.put(datum);
|
||||
if (_buffer.space() == 0)
|
||||
expelBuffer(blockFor);
|
||||
|
@ -128,7 +131,7 @@ public class WebSocketGenerator
|
|||
private synchronized int flushBuffer() throws IOException
|
||||
{
|
||||
if (!_endp.isOpen())
|
||||
throw new IOException("Closed");
|
||||
throw new EofException();
|
||||
|
||||
if (_buffer!=null)
|
||||
return _endp.flush(_buffer);
|
||||
|
@ -138,6 +141,8 @@ public class WebSocketGenerator
|
|||
|
||||
private synchronized int expelBuffer(long blockFor) throws IOException
|
||||
{
|
||||
if (_buffer==null)
|
||||
return 0;
|
||||
int result = flushBuffer();
|
||||
_buffer.compact();
|
||||
if (!_endp.isBlocking())
|
||||
|
|
|
@ -50,16 +50,21 @@ public class WebSocketChatServlet extends WebSocketServlet
|
|||
|
||||
public void onMessage(byte frame, String data)
|
||||
{
|
||||
// Log.info(this+" onMessage: "+data);
|
||||
for (ChatWebSocket member : _members)
|
||||
if (data.indexOf("disconnect")>=0)
|
||||
_outbound.disconnect();
|
||||
else
|
||||
{
|
||||
try
|
||||
// Log.info(this+" onMessage: "+data);
|
||||
for (ChatWebSocket member : _members)
|
||||
{
|
||||
member._outbound.sendMessage(frame,data);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
try
|
||||
{
|
||||
member._outbound.sendMessage(frame,data);
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
Log.warn(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue