-
Notifications
You must be signed in to change notification settings - Fork 0
Server's Model
Server’s Model module consists of two classes, ServerCanvas and MessageHandler. The server works in a passive mode, in the sense that it will only send messages after receiving a new message.
ServerCanvas stores the canvas, the log, the name of the canvas, the name of the manager, and a list of all the users that have joined the whiteboard. All the operations related to the server’s canvas are implemented in this class, as well as user related functionalities such as kicking the user.
MessageHandler handles every message it receives from the Network module. In fact, there is only one public method which can be called by the Network module in MessageHandler, called handleMessage(). Every time the network module receives a message from any client, it calls handleMessage() to generate a list of messages as responses. For instance, if a client sends a new drawing to the server, the MessageHandler will generate a list of the same drawing messages to be sent to all the clients.