Modeling a chat room and clients on the server
All users (clients) of our chat application will automatically be placed in one big public room where everyone can chat with everyone else. The room
type will be responsible for managing client connections and routing messages in and out, while the client
type represents the connection to a single client.
Tip
Go refers to classes as types and instances of those classes as objects.
To manage our web sockets, we are going to use one of the most powerful aspects of the Go community open source third-party packages. Every day, new packages solving real-world problems are released, ready for you to use in your own projects, and they even allow you to add features, report and fix bugs, and get support.
Tip
It is often unwise to reinvent the wheel unless you have a very good reason. So before embarking on building a new package, it is worth searching for any existing projects that might have already solved your very problem. If you find one similar project...