Remote MUD Interfaces

Example 21-4 is a Mud class that serves as a placeholder for inner classes and interfaces (and one constant) used by the rest of the MUD system. Most importantly, Mud defines three Remote interfaces: RemoteMudServer, RemoteMudPerson, and RemoteMudPlace. These define the remote methods that are implemented by the MudServer, MudPerson, and MudPlace objects, respectively.

Example 21-4. Mud.java

package je3.rmi; import java.rmi.*; import java.util.Vector; import java.io.IOException; /** * This class defines three nested Remote interfaces for use by our MUD game. * It also defines a bunch of exception subclasses, and a constant string * prefix used to create unique names when registering MUD servers **/ public class Mud { /** * This interface defines the exported methods of the MUD server object **/ public interface RemoteMudServer extends Remote { /** Return the name of this MUD */ public String getMudName( ) throws RemoteException; /** Return the main entrance place for this MUD */ public RemoteMudPlace getEntrance( ) throws RemoteException; /** Look up and return some other named place in this MUD */ public RemoteMudPlace getNamedPlace(String name) throws RemoteException, NoSuchPlace; /** * Dump the state of the server to a file so that it can be restored * later. All places, and their exits and things, are dumped, but the * "people" in them are not. **/ public void dump(String password, String filename) throws RemoteException, BadPassword, IOException; } ...

Get Java Examples in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.