use of io.fabric8.gateway.handlers.detecting.protocol.openwire.command.WireFormatInfo in project fabric8 by jboss-fuse.
the class OpenwireProtocol method snoopConnectionParameters.
@Override
public void snoopConnectionParameters(final SocketWrapper socket, Buffer received, final Handler<ConnectionParameters> handler) {
OpenwireProtocolDecoder h = new OpenwireProtocolDecoder(this);
h.errorHandler(new Handler<String>() {
@Override
public void handle(String error) {
LOG.info("Openwire protocol decoding error: " + error);
socket.close();
}
});
h.codecHandler(new Handler<Command>() {
@Override
public void handle(Command event) {
if (event instanceof WireFormatInfo) {
WireFormatInfo info = (WireFormatInfo) event;
ConnectionParameters parameters = new ConnectionParameters();
try {
parameters.protocolVirtualHost = info.getHost();
} catch (IOException e) {
e.printStackTrace();
}
handler.handle(parameters);
} else {
LOG.info("Expected a WireFormatInfo frame");
socket.close();
}
}
});
socket.readStream().dataHandler(h);
h.handle(received);
}
Aggregations