// Because is a RoomManager, we know this MUST be a room
final Room room = (Room) roomManager.open(roomUri);
room.addMessageReceivedHandler(new MessageHandler() {
@Override
public void onMessage(final MessageEvent event) {
final Message message = event.getMessage();
display.print(("RECEIVED: " + message.getBody()), Style.received);
pongs++;
if (room.isUserMessage(message) && !room.isComingFromMe(message)) {
final String body = "Pong " + pongs + " [" + System.currentTimeMillis() + "]";
room.send(new Message(body));
display.print("SENT: " + body, Style.sent);
}
}
});
}