Hello,
I have been working on an application built in java that creates a chat interface and connects to a ChatScript server(local).
I am still learning Java and ChatScript so I know im error prone.
the program should connect to the local server, send whatever the user types and recieve the output to display.
The following code I have written is suppose to push a message to the server and recieve the volley in return.
if(ae.getActionCommand().equals("Send")) {
Chat c = new Chat();
// Push Message
c.setFrom(login);
c.setTo(bot);
c.setMessage(chatInput.getText());
chatDisplay.setText(chatDisplay.getText() + c.getFrom() + ": " + c.getMessage() + "n");
// Open Chat Script and send the message
try {
Process p= Runtime.getRuntime().exec(path + args + c.get());
p.waitFor();
InputStream in = p.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write(in.read())
c.set(bot, login,new String(baos.toByteArray()) );
} catch (Exception e) {
e.printStackTrace();
}
//Display output
//c.set(bot, login, "Hello"); //dummy chat
chatDisplay.setText(chatDisplay.getText() + c.getFrom() + ":" + c.getMessage() + "n");
//clear the input {write code}
}
}
any suggestions or advice?