Here is what I have. Note that for testing I am manually inserting the chat ID into the login. This is where the problem lies, I think, because if I print it out, I notice that it continues to increment with each page request.
Is there no way to reconnect with the same chat ID on a subsequent HTTP request?
<%
XMPPConnection conn = new XMPPConnection(“jabber.com”);
The third #login() parameter is a resource identifier. Resources are typically used for identifying the place from where you are connecting (e.g. Home or Work).
If you want to create a Chat using a given chatID then you should use the following constructor Chat(XMPPConnection connection, String participant, String chatID). Otherwise you will have a new chatID for every new Chat.
Questions:
. Will the username/password be different for each HTTP request? The idea of creating a new connection for every request won’‘t scale (i.e. it’'s expensive) in a site with many requests per minute.
. Will the chatID be different for each HTTP request? If you’'ll have the same ID and username/pass then you can create only one XMPPConnection and only one Chat. You will need to keep these objects in memory so you can locate/reuse them for each request.
here is a complete JSP page but I still can’‘t get pollMessage to return anything but null ebven though I’'m succsessfully storing and retrieving a single chat session. Any one ever do this?
The issue is that a chat object is listening for a particular threadID from other users in order to direct the messages to you (messages without that threadID aren’'t delivered through the Chat object). So, you should probably just use a MessageListener instead of a Chat object.
So many people new to Smack have issues with this that I think we need to change the behavior of Chat such that any message from the user you’'re chatting with is delivered to the object.