How to know Typing Status in XMPP openfire using Smack

后端 未结 8 1852
既然无缘
既然无缘 2020-11-30 01:42

I am developing chat application by using Openfire XMPP server. I can text chat between two user. But i want to know Typing status when some one is typing message. So i crea

8条回答
  •  囚心锁ツ
    2020-11-30 01:58

    finally I got the solution. I need to use chat listener along with chat manager and also I need to use in built sendcomposingnotification function. No need to use Messageeventrequestlistener interface or any other custom class for this. I added the following lines,,

    connection.getChatManager().addChatListener(new ChatManagerListener() {
    
                @Override
                public void chatCreated(final Chat arg0, final boolean arg1) {
                    // TODO Auto-generated method stub
    
                    arg0.addMessageListener(new MessageListener()
                    {
    
                        @Override
                        public void processMessage(Chat arg0, Message arg1) 
                        {
                            // TODO Auto-generated method stub
    
                            Log.d("TYpe Stat",title[0] + " is typing......");
                            Toast.makeText(getApplicationContext(),title[0] + " is typing......",Toast.LENGTH_SHORT).show();
                        }
    
    
    
                        }
                    }); 
                }
            });
    

    and also need to send notification like this..

    mem.sendComposingNotification(etRecipient.getText().toString(), message.getPacketID());
            System.out.println("Sending notification");
    

    where mem is type of MessageEventManger. Ref: http://www.igniterealtime.org/builds/smack/docs/latest/javadoc/org/jivesoftware/smackx/MessageEventManager.html

提交回复
热议问题