Openfire Android PubSub订阅请求批准 [英] Openfire Android PubSub Subscription request aproval

查看:97
本文介绍了Openfire Android PubSub订阅请求批准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Openfire和smack的新手,因此我对pubsub功能有疑问.实际上,我创建了一个具有 setAccessModel 作为授权的节点,如下所示.

I am new to Openfire and smack, therefore I have questions regarding pubsub feature. Actually, I have created a node with setAccessModel as authorize, shown below.

PubSubManager mgr = new PubSubManager(xmpp.getConnection());
try {
    LeafNode leaf = mgr.createNode("testNode");
    ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
    form.setAccessModel(AccessModel.authorize);
    form.setDeliverPayloads(true);
    form.setNotifyRetract(true);
    form.setPersistentItems(true);
    form.setPublishModel(PublishModel.open);
    leaf.sendConfigurationForm(form);
} catch (SmackException.NoResponseException e) {
        e.printStackTrace();
} catch (XMPPException.XMPPErrorException e) {
        e.printStackTrace();
} catch (SmackException.NotConnectedException e) {
        e.printStackTrace();
}

我的问题是,当有人要订阅上面的节点时,该节点的所有者如何处理订阅请求?订阅部分如下:

My question is that when somebody wants to subscribe to above node, how the owner of this node can handle the subscription request? Subscription part is as follows:

PubSubManager mgr = new PubSubManager(xmpp.getConnection());

// Get the node
LeafNode node = null;
try {
     node = mgr.getNode("testNode");
     node.addItemEventListener(new ItemEventCoordinator());
     node.subscribe(senderUser+"@desi.loc");
    } catch (SmackException.NoResponseException e) {
        e.printStackTrace();
    } catch (XMPPException.XMPPErrorException e) {
        e.printStackTrace();
    } catch (SmackException.NotConnectedException e) {
        e.printStackTrace();
    }

class ItemEventCoordinator  implements ItemEventListener {
    @Override
    public void handlePublishedItems(ItemPublishEvent items) {
        final ItemPublishEvent itemstemp=items;
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                //stuff that updates ui
                    dspySub.setText("Item: " + itemstemp.getItems());
            }
        });
    }
}

当我设置form.setAccessModel(AccessModel. open )时,一切正常.用户可以轻松地发布和订阅,但是当其AccessModel被授权时,所有者不听,或者可能是我不知道如何使用上述代码在所有者方面处理订阅请求.请引导我.

When I set form.setAccessModel(AccessModel.open) every thing works fine. Users can publish and subscribe easily but when its AccessModel is authorize, owner don't listen, or might be I don't know how to handle subscription request at owner side with above piece of code. Kindly guide me.

推荐答案

贾瓦德,我刚刚回答了另一个关于监听订阅请求的问题.请看一下:

Jawad, I've just replied another guy' question about listening subscription requests. Please take a look:

我如何在smack openfire android中监听传入的订阅请求

我真的希望它能对您有所帮助.

I really hope that it can help you.

祝你好运!

PS .:对不起,但是我没有足够的声誉来发表评论:(

这篇关于Openfire Android PubSub订阅请求批准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆