读取使用咂嘴传入的消息包中发布订阅

编程入门 行业动态 更新时间:2024-10-27 16:37:36
本文介绍了读取使用咂嘴传入的消息包中发布订阅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图使用的Openfire 服务器和 asmack 库来实现PubSub的。 我有这样一种方式,用户已采取了出版商批准配置我的节点

i am trying to implement pubsub using openfire server and asmack library. i have configured my node in such a way that subscribers has to take the approval of publishers

现在我想读的信息使用下面的code 包,但我没有得到任何数据包。我想读消息数据包,因为我想知道每当用户请求发送给出版商获得认购。

now i am trying to read the Message packet using following code but i am not getting any packet. i want to read Message packet because i want to know whenever the subscribers send the request to publishers to get subscribe.

PacketTypeFilter filter = new PacketTypeFilter(org.jivesoftware.smack.packet.Message.class); PacketListener myListener = new PacketListener(){ @Override public void processPacket(Packet packet) { // TODO Auto-generated method stub Log.d("PACKET" , "READ"); if(packet instanceof org.jivesoftware.smack.packet.Message){ org.jivesoftware.smack.packet.Message msg = (org.jivesoftware.smack.packet.Message) packet; Log.d("MY MESSAGE" , msg.toXML()+ ""); } } }; cxmpp.addPacketListener(myListener, filter);

我要的是读取传入消息包

All i want is to read the incoming Message Packets

推荐答案

如果你把所有的配置位和你的PubSub的部件正常工作,然后得到一个正常的消息,你会做这样的事情:

If you have all the configuration bits and your pubsub component correctly working, then for getting a normal message you would do something like:

ConnectionConfiguration config = new ConnectionConfiguration("ADDRESS",PORT); // service name, also known as XMPP domain of the target server. config.setServiceName(this.pubsubServiceAddress); connection = new XMPPConnection(config); connection.connect(); PacketFilter filter = new MessageTypeFilter(Message.Type.normal); connection.addPacketListener(new PacketListener() { public void processPacket(Packet packet) { Message mes = (Message)packet; // do your stuff here } }, filter);

更多推荐

读取使用咂嘴传入的消息包中发布订阅

本文发布于:2023-11-24 11:18:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624992.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:包中   消息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!