Fixes after feedback from Norman.
This commit is contained in:
parent
21b9dd00cd
commit
7c79d6f7b1
@ -16,15 +16,17 @@
|
|||||||
package org.jboss.netty.handler.codec.http.websocketx;
|
package org.jboss.netty.handler.codec.http.websocketx;
|
||||||
|
|
||||||
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
import static org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1;
|
||||||
|
|
||||||
import org.jboss.netty.buffer.ChannelBuffers;
|
import org.jboss.netty.buffer.ChannelBuffers;
|
||||||
import org.jboss.netty.channel.ChannelFutureListener;
|
import org.jboss.netty.channel.ChannelFutureListener;
|
||||||
import org.jboss.netty.channel.ChannelHandler;
|
import org.jboss.netty.channel.ChannelHandler;
|
||||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||||
import org.jboss.netty.channel.ChannelPipeline;
|
import org.jboss.netty.channel.ChannelPipeline;
|
||||||
import org.jboss.netty.channel.ChannelStateEvent;
|
|
||||||
import org.jboss.netty.channel.ExceptionEvent;
|
import org.jboss.netty.channel.ExceptionEvent;
|
||||||
|
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
|
||||||
import org.jboss.netty.channel.MessageEvent;
|
import org.jboss.netty.channel.MessageEvent;
|
||||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
import org.jboss.netty.channel.SimpleChannelHandler;
|
||||||
|
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||||
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
||||||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||||
|
|
||||||
@ -32,7 +34,8 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
|||||||
* Handles WebSocket control frames (Close, Ping, Pong) and data frames (Text and Binary) are passed
|
* Handles WebSocket control frames (Close, Ping, Pong) and data frames (Text and Binary) are passed
|
||||||
* to the next handler in the pipeline.
|
* to the next handler in the pipeline.
|
||||||
*/
|
*/
|
||||||
public class WebSocketServerProtocolHandler extends SimpleChannelHandler {
|
public class WebSocketServerProtocolHandler extends SimpleChannelUpstreamHandler implements
|
||||||
|
LifeCycleAwareChannelHandler {
|
||||||
|
|
||||||
private final String websocketPath;
|
private final String websocketPath;
|
||||||
private final String subprotocols;
|
private final String subprotocols;
|
||||||
@ -53,7 +56,7 @@ public class WebSocketServerProtocolHandler extends SimpleChannelHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelBound(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
|
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
|
||||||
ChannelPipeline cp = ctx.getPipeline();
|
ChannelPipeline cp = ctx.getPipeline();
|
||||||
if (cp.get(WebSocketServerProtocolHandshakeHandler.class) == null) {
|
if (cp.get(WebSocketServerProtocolHandshakeHandler.class) == null) {
|
||||||
// Add the WebSocketHandshakeHandler before this one.
|
// Add the WebSocketHandshakeHandler before this one.
|
||||||
@ -111,4 +114,17 @@ public class WebSocketServerProtocolHandler extends SimpleChannelHandler {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ import org.jboss.netty.channel.ChannelFutureListener;
|
|||||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
import org.jboss.netty.channel.ChannelHandlerContext;
|
||||||
import org.jboss.netty.channel.ChannelPipeline;
|
import org.jboss.netty.channel.ChannelPipeline;
|
||||||
import org.jboss.netty.channel.MessageEvent;
|
import org.jboss.netty.channel.MessageEvent;
|
||||||
import org.jboss.netty.channel.SimpleChannelHandler;
|
import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
|
||||||
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
|
||||||
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
import org.jboss.netty.handler.codec.http.HttpHeaders;
|
||||||
import org.jboss.netty.handler.codec.http.HttpRequest;
|
import org.jboss.netty.handler.codec.http.HttpRequest;
|
||||||
@ -37,7 +37,7 @@ import org.jboss.netty.logging.InternalLoggerFactory;
|
|||||||
/**
|
/**
|
||||||
* Handles the HTTP handshake (the HTTP Upgrade request)
|
* Handles the HTTP handshake (the HTTP Upgrade request)
|
||||||
*/
|
*/
|
||||||
public class WebSocketServerProtocolHandshakeHandler extends SimpleChannelHandler {
|
public class WebSocketServerProtocolHandshakeHandler extends SimpleChannelUpstreamHandler {
|
||||||
|
|
||||||
private static final InternalLogger logger =
|
private static final InternalLogger logger =
|
||||||
InternalLoggerFactory.getInstance(WebSocketServerProtocolHandshakeHandler.class);
|
InternalLoggerFactory.getInstance(WebSocketServerProtocolHandshakeHandler.class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user