}
}
protected void handleUpgradeRequest(ChannelHandlerContext ctx, HttpRequest req) {
//If factory doesn't exist, close the upgrade request channel
WebSocketFactory factory = WebSocketStore.defaultWebSocketStore().factory();
if(factory == null) {
ctx.getChannel().close();
return;
}
WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
ERWOAdaptorUtilities.getWebSocketLocation(req), null, false);
handshaker = wsFactory.newHandshaker(req);
Channel socketChannel = ctx.getChannel();
if(handshaker == null) {
wsFactory.sendUnsupportedWebSocketVersionResponse(socketChannel);
} else {
ChannelFuture future = handshaker.handshake(socketChannel, req);
//TODO tie this to the channel future result?
//Create a WebSocket instance to handle frames
WebSocket socket = factory.create(socketChannel, req);
WebSocketStore.defaultWebSocketStore().takeSocketForChannel(socket, socketChannel);
socket.didUpgrade();
}
}