Sending messages

Now that we can see the conversations that we've been having, we need to add the ability to take part in those conversations--to send new text messages. We'll start on the client. We've actually already seen the handler for the New Message button assigned. It is as follows:

    newMessageBtn.setOnAction(event -> sendNewMessage()); 

What we need to do now is to look at this sendNewMessage() method itself:

 private void sendNewMessage() { Optional<String> result = SendMessageDialogController .showAndWait(conversation.get()); if (result.isPresent()) { Conversation conv = conversation.get(); Message message = new Message(); message.setThreadId(conv.getThreadId()); message.setAddress(conv.getParticipant()); message.setBody(result.get()); ...

Get Java 9: Building Robust Modular Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.