powered by Jive Software

Xxx@gmail.com is offline and can''t receive messages right now

Hello, all;

I’‘m afraid this may be too simple, but I was wondering why the connection does not stay open for me to run the parrot bot. here’'s my code:

import org.jivesoftware.smack.*;

import org.jivesoftware.smack.packet.*;

/**

  • @author Leo

  • @version Aug 31, 2005

*/

public class Test {

public static void main(String[] args) throws XMPPException {

GoogleTalkConnection con= new GoogleTalkConnection();

con.login(“xxxx”,“xxxx”);

    Chat newChat = con.createChat("xxx@gmail.com");

Message newMessage = newChat.createMessage();

while (true) {

// Wait for the next message the user types to us.

Message message = newChat.nextMessage();

// Send back the same text the other user sent us.

newChat.sendMessage(message.getBody());

}

}

}

the answer i get is:

(xxx1: Hi, I’'m an annoying parrot-bot! Type something back to me.)

xxx2: leo!

xxx1@gmail.com/SmackEC68352A is offline and can’'t receive messages right now.

Sent at 12:09 PM on Wednesday

what am I (foolishly) doing wrong?

Thanks,

Leo

Leo,

Google Talk doesn’‘t support thread ID’'s inside chats. So, once you create the Chat object, call:

newChat.setFilteredOnThreadID(false);

We’'re going to add some logic to make this all a bit automated for GoogleTalk connections since it can be very confusing.

Regards,

Matt

Thanks for replying so quickly, Matt. Once again, I’‘m sorry I’‘m so naive about these issues. I hope someone else will benefit from this in the future. Ok, so I added the statement you suggested, I ran it, and it did not come back to me saying I wasn’'t online.

However, it didn’‘t parrot my message either. I don’‘t seem to be able to get the incoming message either, that’‘s why I’'m confused.

Here’‘s more information about my environment, because it may well be that I am not using a useful configuration. Here’'s what I have (running in the same computer):

  1. Two gmail accounts, say a@gmail.com and b@gmail.com, and so 2 googleTalk “persona”;

  2. While I’'m logged in with account a in googleTalk, I login with account “b” in my java program.

No errors are reported anywhere, that’‘s why I’‘m confused. Would you be so kind as to send me a working code snippet that I can just copy and paste? If that doesn’'t work, I should be looking at something different, not the implementation.

Thanks again,

Kind regards,

Leo

A bit more information for those willing to help:

To recapitulate:

  1. I can send a message, but I am not able to “grab” the body of the incoming message.

I started the debugger and the message is actually being received, but if I do something like

Message message = newChat.nextMessage();

System.out.println("–>" + message.getBody());

I don’‘t get the message’‘s text. It seems the “nextMessage” method is doing something I don’‘t really understand, because the line is never reached. It almost seem I’'m using the wrong method. Any ideas?

Best regards,

Leo

I got it. Thanks to Matt. I got confused at the beginning because newChat was my instance, rather than the class, so I got a “the static method in blah should be blah”. Eclipse (smartly enough) just reports it as a warning, rather than an error, so I was just leaving it be (which shows my java inexperience) but I changed it to refer to the Chat class

Chat.setFilteredOnThreadID(false);

instead of

newChat.setFilteredOnThreadID(false);

and it all worked fine.

Thanks very much for everything, it’'s a really nice app. Good Job!

Leo

Leo,

Sorry about that! I should have been a bit more careful when posting the code. I’'m glad you got it working.

Regards,

Matt