It shows how it could look like when two XMPP contacts are chatting with each other and having real-time text enabled. Enjoy!
Roughly speaking you have to create a new outbound real-time message and just update its text while typing:
// Create a chat session with another user. Chat chat = xmppClient.getManager(ChatManager.class).createChatSession(contact); RealTimeTextManager realTimeTextManager = xmppClient.getManager(RealTimeTextManager.class); // Create an new RTT message. OutboundRealTimeMessage realTimeMessage = realTimeTextManager.createRealTimeMessage(chat); TextArea textArea = new TextArea(); textArea.textProperty().addListener((observable, oldValue, newValue) -> { realTimeMessage.update(newValue); });
When done typing, commit the message (which will send the current message as normal chat message):
realTimeMessage.commit();
On the receiver side, you can listen for it like this (and e.g. display it to a Label).
Label label = new Label(); // Upon receiving a RTT message, display it. realTimeTextManager.addRealTimeMessageListener(e -> { InboundRealTimeMessage rtt = e.getRealTimeMessage(); rtt.addRealTimeTextChangeListener(e1 -> Platform.runLater(() -> label.setText(e1.getText()))); });
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI am the main author of XEP-0301.
ReplyDeleteCongratulations on a great implementation of XEP-0301!
I am pleased to hear you found it to be fun as a developer, and fun as a user.
We'd like to hear your comments, if you found any deficiencies in the XEP-0301 standard (e.g. ambiguities, or confusions), for the next round of standard clarifications, if any are needed.
Email -- mark [at] realjabber.org
This comment has been removed by the author.
ReplyDeleteAnother great implementation is now found in talky.io:
ReplyDeletehttps://blog.andyet.com/2015/10/19/talky-gets-real-time-text
The other developers (Lance Stout) agree that XEP-0301 is a fun standard as well; "There are of course more little implementation [UX] details and potential Unicode issues that the XEP-0301 spec covers, but the fundamental model is remarkably simple and fun to implement."
Hi, is it possible if you could do a tutorial on how to implement this? I'm a complete beginner when it comes to xmpp libraries and plugins, and all I've got is a prosody server up and running. I'd love any tips or advice on how to have RTT. Thanks!
ReplyDelete