powered by Jive Software

GroupChat Join Bug

Hi Matt,

I thought I will start fresh here.

Looking at the response from the art@conference.myjabber.net server it does what you said and send the presence with the room/nickname.

Never the less my method does not get this confirmation. Is running it on a separate Thread an issu?

Here is the first thing the server says in the art room:

tedweitz is here

Here is my simple version of run:

public void run() {

try{

groupChat = connection.createGroupChat(room);

groupChat.addMessageListener(this);

groupChat.join(client.login.userName);

groupChat.addParticipantListner(this);

setRoster();

client.tabbedPane.add(room,this );

}

catch(XMPPException ex){

System.out.println("GroupChatClient line 59 Exception: "+ex);}

Never the less it is not working I am missing something, maybe setting up the right listener first.

To complicate things more

The jdev room at jabber.org does not send this type of presence at all it sends

bot0dnd

So it looks like we are relaying on an inconsistent behavior to confirm the login, but even when the server send the right thing my program does not see it.

I am clearly stuck. Maybe some where there is a piece of code for a simple group chat login.

Thanks,

Ted

T

Ted,

I don’'t get:

groupChat.join(client.login.userName);

Somehow, that’'s ‘‘andreaa’’? You are supposed to be using a nickname there.

-Matt

Thanks Matt,

Login.userName is the name the user want to be called So in my case it is tedweitz.

Andrea is the first listing of the room roster.

Somhow the groupChat do not see the returns from the server. If you can please look at my note where I detailed it. If it will help I will be glad to send you the whole project zipped.

Thanks,

Ted

.

Ted,

I know that the unaltered group chat code works fine since we use it all the time. What I’'d recommend is taking the standard Smack code without any changes, then making the simplest possible group chat application to test against your server. Once you get that working, you can slowly add additional code until you find what was going on.

Regards,

Matt

Thanks Matt,

It is unmodified now. Here is all

I try to do. I want to have the most simple GroupChat nothing fancy. I did make it runnable otherwise it is plain as Vanila. Doesn’'t work never the less. Can you beam me the most basic code for one? I have lost all my hair by now

/** A class that handles the sending of packets from the server.

It is running on its own thread as to free the server to handle

calls with out interruption

*/

public class GroupChatClient extends JPanel implements PacketListener, Runnable, ActionListener, KeyListener,

ListSelectionListener, RosterListener, myJAB {

public GroupChatClient(TedsJabber client, XMPPConnection connection, String room){

this.connection = connection;

this.client = client;

this.room = room;

buildUI();

}

public void run() {

try{

groupChat = connection.createGroupChat(room);

groupChat.addMessageListener(this);

groupChat.join(client.login.userName);

setRoster();

client.tabbedPane.add(room,this );

}

catch(XMPPException ex){

System.out.println("GroupChatClient line 59 Exception: "+ex);}

}

Ted,

Perhaps you’'re running into some strange server issues? Can you try testing against our XMPP server? Just use exodus or another client to create an account, then use your code to try to connect to a chat room on “chat.jivesoftware.com

-Matt

Thanks Matt,

That is what I do, just I did it with jabber.org. I can try to go to jivesoftware. Do you think jabber.org is not standard?

Could you beam me a simple code that join a group chat? I thought minr now is simple can you see anything wrong there?

public void run() {

try{

groupChat = connection.createGroupChat(room);

groupChat.addMessageListener(this);

groupChat.join(client.login.userName);

setRoster();

client.tabbedPane.add(room,this );

}

Here is some very simple code for GroupChat functionality:

GroupChat groupChat = con.createGroupChat("test@chat.jivesoftware.com");
groupChat.join("dood");
while (true) {
    Message message = groupChat.nextMessage();
    System.out.println("New message: " + message.getBody());
}

Regards,

Matt

Thanks Matt,

I replaced this code with my code in run and got the same exception

run:

GroupChatClient line 59 Exception: org.jivesoftware.smack.XMPPExcept

ion: No response from server.

public void run() {

try{

      groupChat = connection.createGroupChat("test@chat.jivesoftware.com");

groupChat.join(“dood”);

while (true) {

Message message = groupChat.nextMessage();

System.out.println("New message: " + message.getBody());

}

}

catch(XMPPException ex){

System.out.println("GroupChatClient line 59 Exception: "+ex);}

This is very strange?

Ted

}

Ted,

What version of Smack are you using? Have you made any changes to it?

-Matt

OK,

I think it has to do with this client not registated with the connection as a listner for the packets so it doesn’'t get the response from the server. I will work on it and creat a filter that will accept presance and message types.

Still we will have a problem with jabber.org room that does not respond with the pressance the API is looking for.

Never the less will kill one bug at a time. Thanks Matt,

Ted

Ted,

Are you logging on to the jabber.org server directly or logging on to a local or other server and then joining jdev@jabber.org?

I’'ve noticed that when I am logged on to my local jabber server and then joing a chat on the jabber.org server,it can take up to 30 seconds for the server to send the presence information when you attempt to join a conference room. This is probably due to the local server establishing a channel to the jabber.org server. Once that channel is up, response time will usually be fine.

I use Smack to connect to jabber.org conference rooms without a problems.

Don’‘t know if this is your situation but I thought I’'d point it out just in case it was…

Take care,

John

John,

Interesting, that could be the issue since the timeout is configured to be 5 seconds. Maybe I’'ll need to make an additional join method that takes the timeout value as a param.

-Matt

Thanks a bunch john.

I am connected directly to jabber.org.

When I look at the debug window I see from it a roster info and not the presance packet I thought Smack is looking for. Here is the first response I get when Join.

Could you be so kind and beam me your connection to the room code? I can not see what I am missing here

me@tedweitz.com

Thanks a bunch John,

Ted

Matt,

I’'ve never had a timeout problem since the client is talking to the local server. The connect (as far as the client is concerned) is there, just that it can take a while for the presence info and history messages to come across.

That being said, having the timeout configurable isn’'t a bad idea.

John

Ted,

Here’'s the basic code I use for group chat:

To set it up:

if (conn != null) {

groupChat = conn.createGroupChat(room);

try {

groupChat.addMessageListener(this);

groupChat.addParticipantListner(this);

groupChat.join(nick);

} catch (XMPPException e) {

container.showError(e.getMessage());

}

}

This dispatched the packets to where they need to go:

public void processPacket(Packet packet) {

if (packet instanceof Message) {

processMessage((Message) packet);

}

if (packet instanceof Presence) {

processPresence((Presence) packet);

}

}

Smack pretty much handles all the detail, you just need to process the messages or presence packets.

private void processPresence(Presence presence) {

if (presence.getType() == Presence.Type.AVAILABLE) { …add/update room roster list…}

if (presence.getType() == Presence.Type.UNAVAILABLE) { …remove from room roster list…}

}

John

Thanks John, you are so kind!

I do not understand where my difficulties are (and my head is going to be chopped as my project is due ) I use pretty much the same code. I will list it. I do have a thread though for each room (and chat) as it opens it in a new window (JTabbedPane).

Also looks like you can join jdev@jabber.org. I didn’t see that this room sends back the right presence with the username in the from

BTW I do not see where you register the groupChat as a PacketListener. Took me a while to figure out the need for it.

I can not figure this out my join doesn’'t join the room and I can comunicate with it but do not get the Roster and for Smack I have not joined (I look for the smack joined boolean)

Here is what I do:

public class GroupChatClient extends JPanel implements PacketListener, Runnable, ActionListener, KeyListener,

ListSelectionListener, RosterListener, myJAB {

public GroupChatClient(TedsJabber client, XMPPConnection connection, String room){

this.connection = connection;

this.client = client;

this.room = room;

buildUI();

}

public void run() {

try{

connection.addPacketListener(this,new OrFilter(new PacketTypeFilter(Message.class), new PacketTypeFilter(Presence.class )));

groupChat = connection.createGroupChat(room);

groupChat.addParticipantListner(this);

groupChat.addMessageListener(this);

groupChat.join(client.login.userName);

setRoster();

client.tabbedPane.add(room,this );

}

catch(XMPPException ex){

System.out.println("GroupChatClient line 59 Exception: "+ex);

/*JOptionPane.showMessageDialog(null, “Failed to Join”+ex.getXMPPError().getMessage(),

“alert”, JOptionPane.ERROR_MESSAGE);*/

}

}

public void processPacket(Packet packet){

try{

if (Message.class.isInstance(packet)){

Message msg = (Message)packet;

client.cya(jabbing,"[ "msg.getFrom() " ] "+msg.getBody());

System.out.println(“Is GroupChat joined? :”+groupChat.getJoined());

}

else if (Presence.class.isInstance(packet)){

setRoster();

}

}

catch(Exception e)

{

e.printStackTrace(System.out);

System.out.println("processPacket error "+e);

}

}

public void rosterModified(){

setRoster();

}

Any thoughts