The Engine

This class is the main server class for the Multi-User Environment Server (MUES). The server encapsulates and provides a simple front end/API for the following tasks:

  • Load, configure, and maintain one or more World objects, each of which contains a class library made up of metaclasses stored in a database
  • Handle player connection, login, and player object maintenance through a client protocol or simple telnet/HTTP connection
  • Maintain one or more game Sciences, which provide shared event-driven services to the hosted game worlds
  • Coordinate, queue, and dispatch Events between the World objects, Player objects, and the Sciences.
  • Execute an event loop which serves as the fundamental unit of time for each world

Subsystems

The Engine contains three basic kinds of functionality: thread routines, event dispatch and handling routines, and system startup/shutdown routines.

Threads and Thread Routines

There are currently two thread routines in the Engine: the routines for the main thread of execution and the listener socket. The main thread loops in the MUES::Engine#mainThreadRoutine method, marking each loop by dispatching a MUES::TickEvent, and then sleeping for a duration of time set in the main configuration file. The listener socket also has a thread dedicated to it which runs in the MUES::Engine#listenerThreadRoutine method. This thread waits on a call to accept() for an incoming connection, and dispatches a SocketConnectEvent for each client.

Event Dispatch and Handling

The Engine contains the main dispatch mechanism for events in the server in the form of a MUES::EventQueue. This class is a prioritized scaling thread work crew class which accepts and executes events given to it by the server.

Events are dispatched via one of two methods: the dispatchEvents() method, which dispatches the specified events immediately to the queue for execution, and the scheduleEvents() method, which schedules an event to happen sometime in the future, perhaps more than once.

Startup and Shutdown

[to be continued]

GedTheGreysHain - 15 Jul 2001