I'm building a multiplayer game that includes a chat feature. When players start the game, they enter a password and receive a shareable link to invite their team. This allows others to join the specific game instance, which can host between 100 to 200 users.
I need to implement a chat for each unique game session that only participants can access. The chat doesn't need to store any history; it should only be available while the game session is active. What are the best, quickest, and cheapest methods to implement this feature? I'm open to using libraries, services, or any existing solutions, as long as they support unique chat sessions for each game instance and restrict access to the current players.
5 Answers
Don't forget to consider the backend technology you're using—Node.js or .NET can impact your options for implementation!
WebSockets and WebRTC are the best choices for this setup. If your infrastructure allows it, you might even host the game server on the player's browser and connect the guests' clients directly to them. This could help reduce hosting costs!
Most developers typically use WebSockets for this type of feature. It's relatively straightforward to set it up, and you'll find plenty of libraries available. Just search for "websocket chat room" along with your framework for guidance.
If you're looking for a more inexpensive option, consider using WebRTC for chat rooms. Although it's primarily known for video calls, it should work for text messaging too, and you won't have to worry about keeping a chat history.
You could also approach it with a simple player input and use an event loop to handle messages. If there's no matchmaking involved, throwing messages into an event loop could work well for managing player input.

Related Questions
Ray Trace Simulator – Interactive Optical Ray Tracing Tool
Wordsearch Generator
Random Maze Generator and Solver
Interactive Wheel Spinner Tool – Add Choices and Randomly Pick a Winner
Raffle Ticket Generator
Instant Online Dice Roller