Hi
now this is hard to understand
I run py program once and everything works fine…
Then i stop it and restart it and my Chat’‘s messageListener get’'s no hit anymore…
The XMPPConnection is getting the packet(i see it in the debug window) but my chat’‘s Listener ain’'t notice it
I’‘ve searched the formum but i found nothing like this, i don’‘t expect you to know what’'s wrong with thar feedback info, but someone could have seen something like that before…
Once i restart my pc i can run it again with no prob
The only thing i can imagine is a variable set in memory wich is not cleared, but as i shut down the App the JVM should clear all spaces in memory, or not?
What about the static variables?
Thanks and Regards
this should be the idea
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.*;
import org.jivesoftware.smack.filter.*; public class Informa extends JFrame{ static XMPPConnection con; // so it''s easy to reach static Informa mainF; // and this one too Dialogo nD; public Informa(){
mainF=this;
this.setLayout(new FlowLayout());
try{
con=new XMPPConnection("jabber.org",5222);
PacketListener pL = new PacketListener(){ //this adds a
public void processPacket(Packet packet){//JLabel with
Message mess=(Message)packet; //the message''s body
if (mess.getType()==Message.Type.NORMAL){ //(a JID)
final JLabel mL= new JLabel(mess.getBody());
mL.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {//when clicked create a query
Chat mC= new Chat(Informa.con,mL.getText());
nD= new Dialogo(mC, Informa.con.getUser());
}
});
Informa.mainF.getContentPane().add(mL);
}
}
};
con.addPacketListener(pL,new PacketTypeFilter(Message.class));
con.login("user","pwd"); }catch(Exception e){} }
} class Dialogo{ //this will be in fact a JFrame, but let''s Chat chat; //make it easier, a msg is showed public Dialogo(Chat inChat, String inName){ //everytime chat=inChat; //a packet is recived
chat.addMessageListener(new PacketListener(){
public void processPacket(Packet packet){
System.out.println("got a message");
}
}); }
}
Now the prob. is i’'m not getting messages the second time i run my app
Message was edited by: elfepe
Message was edited by: elfepe
Nicolas,
I tried to reproduce the problem (with the code that you sent me by email) without success. I see that in your PacketListener you are filtering if the message is of Type NORMAL…is it possible that you are receiving messages of type CHAT? Anyway, it’'d be of help if you can specify a step-by-step example in order to reproduce the problem.
Suerte,
– Gato
idk how but i fixed it
the NORMAL was not the problem, it was exactly what i wanted it to do
tks anyway