views:

461

answers:

2

I am using Tapestry 5, Smack api 3.1.0.

I have established a connection and am able to communicate with a user through the xmpp server but the replies i get are sent to the standard output as they come in:

Chat chat = connection.getChatManager().createChat("[email protected]", new MessageListener() {
    public void processMessage(Chat chat, Message message) {
        // Print out any messages we get back to standard out.
        System.out.println("Received message: " + message.getBody());                   // this works

        showonbrowser = message.getBody();                                                   
        System.out.println(showonbrowser) // this prints nothing
    }
};

I am looking to get the replies to my html file so i can read them on the web instead of the console. However, when i try to set message.getBody() to showonbrowser (a property on the page) i see no result. Does anyone know how I get around this?

Regards,

Kace

+1  A: 

Smack is multi-threading and it has a nasty habit of eating up exceptions that are thrown (silently.) Most likely you are not using a thread-safe GUI and its throwing an exception that you never get.

ldog
A: 

I think the processMessage method is being called after the page is rendered.

You are creating a MessageListener instance (through an anonymous class), so you don't know when the processMessage method will be called. I think you would have to do something with AJAX to do partial updates on the page, polling the server and getting any new messages to show them on the page.

Chochos