专业IM即时通讯软件开发,值得信赖!

xmpp openfire+Smack4.3 消息监听

XMPP 云聊IM 151℃

聊天信息监听

chatManager = ChatManager.getInstanceFor(mConnection);
chatManager.addIncomingListener(new IncomingChatMessageListener() {
    @Override
    public void newIncomingMessage(EntityBareJid messageFrom, Message message, Chat chat) {
     
    }
});

headline监听

mConnection.addAsyncStanzaListener(new StanzaListener() {
    @Override
    public void processStanza(Stanza packet) throws SmackException.NotConnectedException, InterruptedException {
        Message headlineMessage = (Message) packet;
     
    }
}, MessageTypeFilter.HEADLINE);

incomingListenter只会监听到Type为chat类型和nomal,想要监听到headline类型的要用StanzaListener。

喜欢 (0)
仿微信聊天软件开发
点击这里给我发消息