Question

Is there any way to find out whether the Quickblox multiple user are online with ANDROID ? QBChatService wraps the connection, i am not sure how to achieve this, also i thought using the roster, but i don't see where can i get the roster, can you please advise.I am using video chat Module of quickblox

How to add QBChatService.getInstance().addNotMessageListener(packetListener) QBChatService.getInstance().sendCustomPresence(presence)

in video chat module

Was it helpful?

Solution

You can find examples using roster and other features in QB snippets: enter link description here

After you logged in video chat, you can get roster using:

QBChatRoster roster = QbChatService.getInstance().registerRoster(new QBChatRoster.QBRosterListener() {
        @Override
        public void entriesDeleted(Collection<String> users) {

        }

        @Override
        public void entriesAdded(Collection<String> users) {
            //List<Integer> usersId = qbChatRoster.getUsersId();
            for (String s : users) {
                Log.i(TAG, "roster added="+s);
            }
        }

        @Override
        public void entriesUpdated(Collection<String> users) {
            for (String s : users) {
                Log.i(TAG, "roster updated="+s);
            }
        }

        @Override
        public void presenceChanged(Presence presence) {
            Log.i(TAG, "presence changed="+presence.getFrom() + " "+presence.getType());
        }
    });

Be careful. Instance of QBChatService will be instantiated when you start VideoChat.

In presenceChanged() method you can check whicn one available or nonavailable. You can listen for "available"/"nonavailable" presence using:

QBChatService.getInstance().addNotMessageListener(packetListener);

And you can add friend using:

qbChatRoster.createEntry(int userId, String name, String[] groups)

which will send request to user and add his data to roster.

Using:

QbChatService.getInstance().sendCustomPresence(Presence presence) 

you can send raw presence. For example to confirm request to add you as friend - which you can get in NotMessageListener.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top