I'm working on a chat app where users can join different classes. I'm trying to decide whether to use sockets or a REST API for handling the class joining process. For context, the app uses Socket.IO for the actual chatting feature. What would be the best approach? Should I emit an event when a user wants to join, or would it make more sense to use a REST API for that part?
5 Answers
I would recommend going with a REST API to handle the class joining. You can use sockets to notify the class when someone joins, making the process cleaner and more organized.
If your users can join classes on their own, a REST API works great. But if you need approval for joining a class, consider using sockets to notify the owner immediately. It really depends on how interactive you want the process to be.
What do you mean by "classes" in this context? Are you talking about chat rooms that are currently active?
You might want to consider using CQRS. Have a command to join and a query for the student list or whatever needs to be displayed.
Using a REST API for joining a class is definitely the way to go. Save sockets for the chat functionality to keep it efficient.
Related Questions
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads