I am implementing pubsub model to achieve group chat. All things are working well. I am able to create node, other users subscribe the node, publish item by owner or subscriber and item is getting to all subscriber.
Now i have requirement, the owner(User creating node) should be able to subscribe node to roster users and subscribed user start getting item publish.
Is there any way to achieve this?
My node creation code is below:
ConfigureForm form = new ConfigureForm(DataForm.Type.submit);
form.setPersistentItems(false);
form.setDeliverPayloads(true);
form.setAccessModel(AccessModel.open);
form.setPublishModel(PublishModel.open);
setSubscribers(form);
LeafNode node = (LeafNode) manager.createNode(nodeName, form);
As document says it is possible to autosubscribe to a node, based on access model which may be roster/presence/open access model.
Related
I'm making a social media app like Facebook using Flutter and Firebase.
I'm using Firebase Cloud Messaging to make notification service.
I want to make users who joined community or groups to subscribe their group's topic. Therefore, I can send notification to them by using method which is "subscribeToTopic()". However, I don't know how to make all users in community or groups to subscribe to certain topics.
If you know how to make all users to subscribe to certain topics, please let me know. Thank you!
There is no API to get the current subscribers to a topic, nor is there an API that verbatim subscribes all subscribers to one topic to another topic.
If you already track group membership yourself, you can either let each client subscriber themselves to the additional topic, or you can determine the list of tokens for the group members and then subscribe them to the topic on the server.
How to get offline message in PubSub? Using the Smack library. after searching I found an answer which looks like this:
// Create a pubsub manager using an existing XMPPConnection
PubSubManager mgr = PubSubManager.getInstanceFor(con);
// Get the node
LeafNode node = mgr.getNode("testNode");
List<? extends Item> items = node.getItems(100);
But node.getItems(100) returns last 100 messages, which can be online and offline too.
1) how to keep track of online and offline message in pubsub using smack?
2) is it possible to get unread message count in pubsub using smack? if yes then how to achieve it?
3) how to know that who(publisher) send this message in a node?
I just went through the documentation of Smack and PubSub from here
and here but didn't find the solutions related to my queries. So can anyone help me to solve this?
1) how to keep track of online and offline message in pubsub using
smack?
I would suggest using the PubSub item ID.
2) is it possible to get unread message count in pubsub using smack?
if yes then how to achieve it?
PubSub nodes don't have a per subscribed unread message count.
If you want to catch-up on all new items since you received the last item from a PubSub node, you'd usually remember the last item's ID and use that to query for all newer items on the PubSub node. Unfortunately there is (currently) no way to query a PubSub node for newer items after a certain ID.
But if you are subscribed to a node, then the service will notify you about new items even if you are offline. And if your server stores those offline messages for you, then you will receive them eventually.
3) how to know that who(publisher) send this message in a node?
Unfortunately there is no reliable way to the the JID of the entity which published an item. This too, could probably be fixed with an extension XEP.
First from this question :
Asmack/openfire How do I keep a user permanently in groupchat room
I read that I cannot use MUC to keep the user persistent in the group, they'll automatically leave the group and can rejoin after they come online again, that concept is like IRC like what've been asked in here -> http://community.igniterealtime.org/thread/48020.
Then from the stackoverflow question I read about using pubsub, then I've done some research about pubsub and what I've got is pubsub can persist the user to be in the group even the user is offline but the message flow is more like one directional from the publisher to the subscriber (read-only).
So if I want to create a group chat application can I use pubsub and set all the member to become both publisher and subscriber? or is there any alternative solution?or my understanding of the pubsub and MUC is incorrect?
my goal is to create some group chat like in the whatsapp or blackberry messenger group.
Thanks.
You can make users permanent in Group chat in MUC by changing the following code of openfire.
File : src/java/org/jivesoftware/openfire/muc/spi/LocalMUCUser.java
change line 547-550:
// TODO Consider that different nodes can be creating and processing this presence at the same time (when
remote node went down)
removeRole(group);
role.getChatRoom().leaveRoom(role);
TO:
// TODO Consider that different nodes can be creating and processing this presence at the same time (when
remote node went down)
// TODO Dont remove user from group when they go offline.
//removeRole(group);
//role.getChatRoom().leaveRoom(role);
I'm using the fontis magento/campaign monitor extension; installation all OK, apart from new subscribers are being added to directly to the unsubscribe list rather than the subscriber list. I'm using my CM API Key (the client key doesn't seem to work) and the API list ID for the client's list. Any thoughts as to where I've gone wrong.
Some client subscribe a node, I want to know how to get the subscriber.
Is there some plugins in the Openfire can do this?
You will need to build the smack version from the repo to get PubSub support. See my blog for details. Once you have build smack, this is how you retrieve the list of subscribers
//Assume pubsub jid is pubsub.myserver
PubSubManager mgr = new PubSubManager(conn, "pubsub.myserver");
//Assume we are dealing with leafnode
LeafNode node = (LeafNode)mgr.getNode("mynode");
List<Subscriptions> subscriptions = node.getSubscriptions();