Server Implementation



  The server is divided into two primary components, each of which runs on a
separate thread.  The mainline server handles the object database and the
majority of the processing associated with handling the clients.  The network
thread handles all communication with the network.

  When the server is run, it initializes itself by binding a socket to the port
specified on the command line.  It then initializes its object database (known
as the 'world'), and enters into its main loop.  The main loop continuously
looks for new connections, and runs the mainline processing for each client.


'Network'

This component maintains all information associated with network communications. It maintains a list of all the currently connected clients as well. Its primary purpose, though, is to move events (packets) back and forth across the network. When some part of the mainline code needs to send an event to a client, it passes the event to the network, which places it in an outgoing event queue. The network thread then takes all pending events and sends them to their respective clients. A similar process is used to handle incoming events, which are placed on an incoming event queue as they are received, and removed from it as the mainline code requests them. In order to maintain the integrity of these queues, all access to them is governed by two mutexes.

'Client'

This somewhat confusingly named component of the server maintains all the information for a currently connected client. This includes packet sequencing information (which must be specific to each client) and a list of the agents controlled by this client.

'Agent'

This component maintains the state of each agent in the world. One agent structure is allocated for each agent. The information maintained by each such structure includes the agent's position, orientation, velocity, and other state information.

'World'

The world component maintains the list of all agents. This is basically the primary world database. At present, it only contains a single linked-list of agents, though that will most likely change as more complex structures are implemented, such as container objects.