Client Server Organization - pc2ccs/pc2v9 GitHub Wiki

Each PC² module (Server, Admin, Judge, etc.) operates within itself and on its own machine following the Model-View-Controller (MVC) architecture as described in the PC2V9 Architectural Overview page. However, modules communicate with each other using a Client-Server model. In the case of the PC2 system, the PC2 Server module is the "server", and all the other modules (Admin, Judge, Team, etc.) are "clients".

Communication between modules is accomplished by sending PC2 Packets. For example, whenever a client (say, an Admin, or a Team) wants to communicate with the server, it does so by constructing a “packet” of information and sending that packet to the server using a PC² software layer called the “Transport”. Similarly, the server communicates with its connected clients by constructing and sending packets. (Note that clients never communicate with other clients; they communicate only with the PC² server.)

Module-to-Module communication (that is, packet transmission and reception) is handled by dividing each module into two distinct layers. The upper layer -- the application itself -- is responsible for determining what type of packet it wishes to send and is responsible for processing received packets. The lower layer, called the Transport Layer, receives requests from the application layer to send a packet and arranges for that packet to be broadcast over the network addressed to its intended recipient. The transport layer also accepts packets from the network and forwards them to registered listener routines in the application layer.

All modules use this same two-layer structure, and the code which implements it is the same actual source code regardless of which module is being considered. That is, there is one set of "transport layer" code (located in package core.transport), and it is this single set of code which is invoked to handle network transmissions regardless of which module is being looked at; likewise, there is one set of "application layer" code that handles packet generation and reception. (That is, there is one common code base for all application layer packet-handling operations; there is not for example a separate set of application layer package-handling code for the "Judge module", the "Team Module", etc.)