powered by Jive Software

Messagelistener doesn't work

Hello everyone,

I want to build an IM system based on openfire. But there’s a problem confusing me.

I have a chatlistener and a messagelistener in my program, but the messagelistener never work well.

Here’s my code:

chatmanager.addChatListener(new ChatManagerListener(){
                                        public void chatCreated(Chat chat,boolean createdLocally){
                                                            chat.addMessageListener(new MessageListener(){
                                                                      public void processMessage(Chat chat,Message message){
                                                                                String messageBody=message.getBody();
                                                                                String messageFrom=message.getFrom();
                                                                                System.out.println("receivefrom:"+messageBody+" "+messageFrom);
mychat=chatmanager.createChat("admin@strong", new MessageListener(){                                         @Override
                                        public void processMessage(Chat arg0, Message arg1) {
                                                  // TODO Auto-generated method stub
                                                  String messageBody=arg1.getBody();
                                                  String messageFrom=arg1.getFrom();

Thank you all.