Stilts 0.1.0-SNAPSHOT

org.projectodd.stilts.stomp.server.websockets.protocol
Class HandshakeHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by org.projectodd.stilts.stomp.server.websockets.protocol.HandshakeHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class HandshakeHandler
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler

Multi-verison handshake handler for the web-sockets protocol family.

Author:
Trustin Lee, Michael Dobozy, Bob McWhirter
See Also:
Handshake

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
org.jboss.netty.channel.ChannelHandler.Sharable
 
Constructor Summary
HandshakeHandler()
          Construct.
 
Method Summary
protected  void decodeHost(org.jboss.netty.channel.ChannelHandlerContext channelContext, org.jboss.netty.handler.codec.http.HttpRequest request)
           
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
protected  Handshake findHandshake(org.jboss.netty.handler.codec.http.HttpRequest request)
          Locate a matching handshake version.
protected  void forwardConnectEventUpstream(org.jboss.netty.channel.ChannelHandlerContext channelContext)
           
protected  void handleHttpRequest(org.jboss.netty.channel.ChannelHandlerContext channelContext, org.jboss.netty.handler.codec.http.HttpRequest request)
          Handle initial HTTP portion of the handshake.
protected  boolean isWebSocketsUpgradeRequest(org.jboss.netty.handler.codec.http.HttpRequest request)
          Determine if this request represents a web-socket upgrade request.
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent e)
           
protected  void reconfigureDownstream(org.jboss.netty.channel.ChannelPipeline pipeline)
          Remove HTTP handlers, replace with web-socket handlers
protected  void reconfigureUpstream(org.jboss.netty.channel.ChannelPipeline pipeline)
          Remove HTTP handlers, replace with web-socket handlers.
 
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandshakeHandler

public HandshakeHandler()
Construct.

Parameters:
contextRegistry - The context registry.
Method Detail

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent e)
                     throws Exception
Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

handleHttpRequest

protected void handleHttpRequest(org.jboss.netty.channel.ChannelHandlerContext channelContext,
                                 org.jboss.netty.handler.codec.http.HttpRequest request)
                          throws Exception
Handle initial HTTP portion of the handshake.

Parameters:
channelContext -
request -
Throws:
Exception

forwardConnectEventUpstream

protected void forwardConnectEventUpstream(org.jboss.netty.channel.ChannelHandlerContext channelContext)

decodeHost

protected void decodeHost(org.jboss.netty.channel.ChannelHandlerContext channelContext,
                          org.jboss.netty.handler.codec.http.HttpRequest request)

findHandshake

protected Handshake findHandshake(org.jboss.netty.handler.codec.http.HttpRequest request)
Locate a matching handshake version.

Parameters:
request - The HTTP request.
Returns:
The matching handshake, otherwise null if none match.

reconfigureUpstream

protected void reconfigureUpstream(org.jboss.netty.channel.ChannelPipeline pipeline)
Remove HTTP handlers, replace with web-socket handlers.

Parameters:
pipeline - The pipeline to reconfigure.

reconfigureDownstream

protected void reconfigureDownstream(org.jboss.netty.channel.ChannelPipeline pipeline)
Remove HTTP handlers, replace with web-socket handlers

Parameters:
pipeline - The pipeline to reconfigure.

isWebSocketsUpgradeRequest

protected boolean isWebSocketsUpgradeRequest(org.jboss.netty.handler.codec.http.HttpRequest request)
Determine if this request represents a web-socket upgrade request.

Parameters:
request - The request to inspect.
Returns:
true if this request is indeed a web-socket upgrade request, otherwise false.

exceptionCaught

public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.ExceptionEvent e)
                     throws Exception
Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
Exception

Stilts 0.1.0-SNAPSHOT

Copyright © 2011 JBoss, a division of Red Hat, Inc.. All Rights Reserved.