Cosmetics.
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1440 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
05da23b3c6
commit
5118ba49ac
|
@ -18,7 +18,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
final long _timestamp;
|
||||
final WebSocket _websocket;
|
||||
final int _maxIdleTimeMs=300000;
|
||||
|
||||
|
||||
public WebSocketConnection(WebSocket websocket, EndPoint endpoint, WebSocketBuffers buffers, long timestamp, long maxIdleTime)
|
||||
{
|
||||
_endp = endpoint;
|
||||
|
@ -28,7 +28,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
_parser = new WebSocketParser(buffers, endpoint, new WebSocketParser.EventHandler()
|
||||
{
|
||||
public void onFrame(byte frame, String data)
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
_websocket.onMessage(frame,data);
|
||||
|
@ -42,13 +42,13 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
Log.warn(th);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onFrame(byte frame, Buffer buffer)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] array=buffer.array();
|
||||
|
||||
|
||||
_websocket.onMessage(frame,array,buffer.getIndex(),buffer.length());
|
||||
}
|
||||
catch(ThreadDeath th)
|
||||
|
@ -61,7 +61,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// TODO should these be AsyncEndPoint checks/calls?
|
||||
if (_endp instanceof SelectChannelEndPoint)
|
||||
{
|
||||
|
@ -81,24 +81,24 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
_idle = new IdleCheck()
|
||||
{
|
||||
public void access(EndPoint endp)
|
||||
{}
|
||||
{}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Connection handle() throws IOException
|
||||
{
|
||||
boolean progress=true;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
while (progress)
|
||||
{
|
||||
int flushed=_generator.flush();
|
||||
int filled=_parser.parseNext();
|
||||
|
||||
progress = flushed>0 || filled>0;
|
||||
|
||||
|
||||
progress = flushed>0 || filled>0;
|
||||
|
||||
if (filled<0 || flushed<0)
|
||||
{
|
||||
_endp.close();
|
||||
|
@ -129,7 +129,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
{
|
||||
return _endp!=null&&_endp.isOpen();
|
||||
}
|
||||
|
||||
|
||||
public boolean isIdle()
|
||||
{
|
||||
return _parser.isBufferEmpty() && _generator.isBufferEmpty();
|
||||
|
@ -147,10 +147,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
|
||||
public void sendMessage(String content) throws IOException
|
||||
{
|
||||
_generator.addFrame(WebSocket.SENTINEL_FRAME,content,_maxIdleTimeMs);
|
||||
_generator.flush();
|
||||
checkWriteable();
|
||||
_idle.access(_endp);
|
||||
sendMessage(WebSocket.SENTINEL_FRAME,content);
|
||||
}
|
||||
|
||||
public void sendMessage(byte frame, String content) throws IOException
|
||||
|
@ -163,10 +160,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
|
||||
public void sendMessage(byte frame, byte[] content) throws IOException
|
||||
{
|
||||
_generator.addFrame(frame,content,_maxIdleTimeMs);
|
||||
_generator.flush();
|
||||
checkWriteable();
|
||||
_idle.access(_endp);
|
||||
sendMessage(frame, content, 0, content.length);
|
||||
}
|
||||
|
||||
public void sendMessage(byte frame, byte[] content, int offset, int length) throws IOException
|
||||
|
@ -201,7 +195,7 @@ public class WebSocketConnection implements Connection, WebSocket.Outbound
|
|||
if (!_generator.isBufferEmpty() && _endp instanceof AsyncEndPoint)
|
||||
((AsyncEndPoint)_endp).scheduleWrite();
|
||||
}
|
||||
|
||||
|
||||
private interface IdleCheck
|
||||
{
|
||||
void access(EndPoint endp);
|
||||
|
|
Loading…
Reference in New Issue