I started passing the input user ID in a HashSet, but this caused problems when handling multiple users in different chat rooms. Despite the efforts, the data structure was unable to effectively manage the typing status of different rooms, leading to issues such as the inability to properly track users.
I used a HashMap instead, where the keys are the room IDs and the values are a HashSet of user IDs entered in that room. Furthermore, this is the most concise: it organizes the code better and will show the receipt of input indicators for each chat room.
Thanks to this update, the method of tracking typing activity has become more reliable, resulting in a better experience for users while eliminating any errors previously encountered. The new structure not only improves performance by minimizing checks that don’t need to be completed, but also enables data to be entered in memory for each room, making the application more scalable and stable.