Created
February 11, 2014 14:59
-
-
Save chirino/8936409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void handle(final NetSocket socket) { | |
socket.dataHandler(new Handler<Buffer>() { | |
Buffer received = new Buffer(); | |
@Override | |
public void handle(Buffer event) { | |
received.appendBuffer(event); | |
LOG.info("Received a buffer, matching protocols against: " + received.length()); | |
for (final Protocol protocol : protocols) { | |
if( protocol.matches(received) ) { | |
protocol.snoopConnectionParameters(socket, received, new Handler<ConnectionParameters>() { | |
@Override | |
public void handle(ConnectionParameters connectionParameters) { | |
// this will install a new dataHandler on the socket. | |
route(socket, connectionParameters, received); | |
} | |
}); | |
return; | |
} | |
} | |
if( received.length() >= maxProtocolIdentificationLength) { | |
LOG.info("Connection did not use one of the enabled protocols "+getProtocolNames()); | |
socket.close(); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment