You have not posted any code or idea of your own, hence I can’t comment or tell you very specific things to your idea/code. But I’d try to be broad enough for this.
Using a special node like status
and setting it to online
and offline
will be a good idea.
You can use orderByChild()
to order all the users with status
node set to online
and get the uid
of any of those users.
To make the process random you could make a call to users
, take the ids given back to you, and pick one at random with a basic random number.
If after making a call to users you have 10 user ids in an array you would want to get a random number between 0-9 and then make a call to firebase with the userId.
I don’t believe Firebase has any built in code for this. So this would be the best thing you can do to achieve this feature in your app.
You may also refer this question.
solved Connect random users in Google Firebase [closed]