【发布时间】:2012-03-18 14:48:50
【问题描述】:
实际上,问题是当我的xmpp客户端发送朋友邀请,然后收件人已经批准邀请时,openfire服务器再次向发起者/邀请发送者推送订阅数据包以进行授权,这就是我想要阻止的原因这是通过使用 IQ 标签自动过滤它,然后自动授权它。
但是使用 PacketListener,我无法获得 IQ 标签...
我该怎么做?
@Override
public void processPacket(Packet packet) {
Log.i(TAG, "SECOND subscription");
Log.d(TAG, "SECOND: "+packet.toXML());
if (packet instanceof Presence) {
Presence p = (Presence) packet;
Log.d(TAG, "TYPE-Presence: "+p.getType());
if (p.getType() != Presence.Type.subscribe)
return;
String from = p.getFrom();
Log.d(TAG, "PACKET from: "+from);
Notification notification = new Notification(android.R.drawable.stat_notify_more, mService.getString(
R.string.AcceptContactRequest, from), System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
Intent intent = new Intent(mService, Subscription.class);
intent.setData(Contact.makeXmppUri(from));
notification.setLatestEventInfo(mService, from, mService
.getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0,
intent, PendingIntent.FLAG_ONE_SHOT));
int id = p.hashCode();
mService.sendNotification(id, notification);
}
}
【问题讨论】: