Fixing expectations of internal impl now that WebSocketSession exists

This commit is contained in:
Joakim Erdfelt 2012-07-17 10:15:11 -07:00
parent 249595882c
commit 6ece593c58
3 changed files with 40 additions and 6 deletions

View File

@ -20,7 +20,7 @@ import java.util.concurrent.ExecutionException;
import org.eclipse.jetty.util.FutureCallback;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
import org.eclipse.jetty.websocket.io.RawConnection;
import org.eclipse.jetty.websocket.io.WebSocketSession;
import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
/**
@ -30,17 +30,17 @@ import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
*/
public class WebSocketBlockingConnection
{
private final RawConnection conn;
private final WebSocketSession conn;
public WebSocketBlockingConnection(WebSocketConnection conn)
{
if (conn instanceof RawConnection)
if (conn instanceof WebSocketSession)
{
this.conn = (RawConnection)conn;
this.conn = (WebSocketSession)conn;
}
else
{
throw new IllegalArgumentException("WebSocketConnection must implement internal RawConnection interface");
throw new IllegalArgumentException("WebSocketConnection must implement internal WebSocketSession interface");
}
}

View File

@ -18,8 +18,24 @@ package org.eclipse.jetty.websocket.api.io;
import java.io.IOException;
import java.io.OutputStream;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
import org.eclipse.jetty.websocket.io.WebSocketSession;
public class WebSocketOutputStream extends OutputStream
{
private final WebSocketSession conn;
public WebSocketOutputStream(WebSocketConnection conn)
{
if (conn instanceof WebSocketSession)
{
this.conn = (WebSocketSession)conn;
}
else
{
throw new IllegalArgumentException("WebSocketConnection must implement internal WebSocketSession interface");
}
}
@Override
public void write(int b) throws IOException

View File

@ -17,9 +17,28 @@ package org.eclipse.jetty.websocket.api.io;
import java.io.IOException;
import java.io.Writer;
import java.nio.charset.Charset;
import org.eclipse.jetty.util.StringUtil;
import org.eclipse.jetty.websocket.api.WebSocketConnection;
import org.eclipse.jetty.websocket.io.WebSocketSession;
public class WebSocketWriter extends Writer
{
private final Charset charset = StringUtil.__UTF8_CHARSET;
private final WebSocketSession conn;
public WebSocketWriter(WebSocketConnection conn)
{
if (conn instanceof WebSocketSession)
{
this.conn = (WebSocketSession)conn;
}
else
{
throw new IllegalArgumentException("WebSocketConnection must implement internal WebSocketSession interface");
}
}
@Override
public void close() throws IOException
@ -41,5 +60,4 @@ public class WebSocketWriter extends Writer
// TODO Auto-generated method stub
}
}