O'Reilly logo

Java Examples in a Nutshell, 3rd Edition by David Flanagan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The MUD Server

Example 21-5 shows the MudServer class. This class is a standalone program that starts a MUD running; it also provides the implementation of the RemoteMudServer interface. As noted before, a MudServer object merely serves as the entrance to a MUD: it is not the MUD itself. Therefore, this is a fairly simple class. One of its most interesting features is the use of the serialization classes of java.io and the compression classes of java.util.zip to save the state the MUD, so that it can be restored later.

Example 21-5. MudServer.java

package je3.rmi; import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; import java.io.*; import java.util.Hashtable; import java.util.zip.*; import je3.rmi.Mud.*; /** * This class implements the RemoteMudServer interface. It also defines a * main( ) method so you can run it as a standalone program that will * set up and initialize a MUD server. Note that a MudServer maintains an * entrance point to a MUD, but it is not the MUD itself. Most of the * interesting MUD functionality is defined by the RemoteMudPlace interface * and implemented by the RemotePlace class. In addition to being a remote * object, this class is also Serializable, so that the state of the MUD * can be saved to a file and later restored. Note that the main( ) method * defines two ways of starting a MUD: one is to start it from scratch with * a single initial place, and another is to restore an existing MUD from a * file. **/ public class MudServer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required