if (args == null) {
throw new RuntimeException("No arguments passed to main");
}
final BarchartFeedReceiver client = new BarchartFeedReceiver();
final MarketInstrument[] instruments = new MarketInstrument[args.length
- INST_START];
for (int i = INST_START; i < args.length; i++) {
instruments[i - INST_START] = client.lookup(args[i]);
}
if (args[0].equals("TCP")) {
client.listenTCP(Integer.parseInt(args[1]), false);
} else if (args[0].equals("UDP")) {
client.listenUDP(Integer.parseInt(args[1]), false);
} else {
throw new RuntimeException("Bad protocol, expecting UDP or TCP");
}
client.addAllMarketsTaker(TakerFactory.makeTaker(instruments));
System.in.read();
client.shutdown();
System.exit(0);
}