outputStreamsString = args[4];
}
String[] outputStreams = outputStreamsString.split(" ");
Driver d = new Driver(hostName, port);
Reader inputReader = null;
BufferedReader br = null;
try {
if (!d.init()) {
System.err.println("Driver initialization failed");
System.exit(1);
}
d.setReadMode(ReadMode.All);
if (outputStreams.length > 0) {
d.setReadMode(ReadMode.Select);
for (String outputStream : outputStreams) {
System.out.printf("Registering output stream name '%s'\n", outputStream);
d.readInclude(outputStream);
}
}
if (!d.connect()) {
System.err.println("Driver initialization failed");
System.exit(1);
}
inputReader = new InputStreamReader(System.in);
br = new BufferedReader(inputReader);
// send all messages
for (String inputLine = null; (inputLine = br.readLine()) != null;) {
Message m = new Message(streamName, clazz, inputLine);
d.send(m);
}
// read all responses
while (true) {
Message response = d.recv();
System.out.println(response);
}
/*List<Message> responses = d.recvAll(999999999);
for (Message message : responses) {
System.out.println(message);
}*/
} catch (IOException e) {
e.printStackTrace();
}
finally {
try { d.disconnect(); } catch (Exception e) {}
try { br.close(); } catch (Exception e) {}
try { inputReader.close(); } catch (Exception e) {}
}
}