I’m working on building a random video chat app similar to Omegle or Ome.tv. I’ve already handled the basics, but I’m currently stuck on the part where I need to create a room system that connects two users at random. I’ve tried using a few plugins in the past, but they didn’t work quite the way I needed. I’m looking for help specifically with the matchmaking and room connection logic.
Hi @iamjake333
I am not sure if you really need plugins for creating chatroom. Please share if i am missing some parameters here.
If i were you,
I would have a user table with a field called “is_live”. Anytime a user logs in, i update the is_live to yes. (You will need some kind of session logic to maintain this status reasonably)
Anytime a user clicks on “join/match”, I would
- Create a new object called chatroom with participants as “list of user” or simply 2 fields called user1 and user2(again that depends on your use case)
- Do a search for : users: random item → assign that to user1
- Do a search for : users(minus the 1 user already selected in step 2): random item → assign that to user2
And there you have it.
Then you could have a plugin for video call or message chat whatever you need to facilitate that interaction.
Let me know if you needed help in anything besides that?
I have when the button is click → create a new chatroom (type chatroom) → make changes to user… (thing to change - Search for user:random item’s user-2
I’ve updated it. Image B is clicked → Create a nee chatroom (fields are user1 = Current User user2 = search for users:random item) → Make changes to user (search for users:random item)
@maindola.yogini Ive changed things.
Element Event
Image B is clicked
Step1
Create a new Chatroom…
Type Chatroom
User 1 = Current User
User 2 =
Room ID = Calculate RandomString
Is Full = no
Step 2
Go to page index
Data to Send: Result of step 1
Send more parameters to the page
Key [room_id] = result of step 1’s room ID
Now how would I make it connect to a random chatroom instead of creating a new one if one is open?
Hi @iamjake333
What is happening on Index page when you pass the chatroom data there?
I realized that chatroom problem is a little more complex than simply selecting 2 users and add them into a chatroom. It would be impossible to know when to create a chatroom and when to add a user to existing chatroom.
To get around this, instead of creating a chatroom whenever any user clicks join chat, you would make a a 2 step process. Where each step runs independently of each other.
- process 1 : Whenever any user wants to join chatroom, add them to a new table called waiting list.
- process 2: As long as there are 2 or more people in the waiting list, keep creating chatroom with 2 random people.
That way a chatroom is only created when you have 2 verified people who are available now to chat.
Besides this there are couple of other things you need to account for. Its very simple to add people in the waiting list, but the trick is that you always need to keep it latest. You will need to decide what to do when
- a user was in waiting list but their tab when inactive for few seconds, while they were checking out some other site
- or they closed the app
- or they had a temporary network issue
Its a bit difficult to track user inactivity in bubble right out of box, since it doesn’t tell you explicitly with an event. The only thing you can do is run a recurring event and keep checking that the user is active or not, but that can typically take a lot of WU and still not give you accurate data. You can use some plugins to detect this, which i have linked here.
Secondly, even after using the plugins, there is no guarantee that every once in a while you get a chatroom with 1 user who just exited when they were getting added to the chatroom or lost interest after being matched with someone.
One way to go is that, once a chatroom is created, the user must click on “start chat” in next 15 seconds. If not, they are considered absconded and are removed from the chatroom and waiting list. Whereas the other user is moved back to waiting list to connect with someone else. The chatroom status is updated to completed or abandoned.
The overall idea is that this system relies on accurately identifying and connecting 2 active users, so you need to think and cover a lot of edge cases to find the balance between a good UX a reliable chat experience and not overload bubble with ton of workflows just to keep verifying if a user is active or not.