// // Othecko 1.1 // // Steve Matuszek // Jack Freelander // University of North Carolina at Chapel Hill // // // MessageObject.java // Jack Freelander 1.0 // // This class is a wrapper for a variety of messages that may // be passed between MiddleMen, GameServers, and OtheckoApplets. // import java.util.*; import java.io.*; public class MessageObject implements Serializable { public static final int VOTE = 1; public static final int SUGGEST_PARENT = 2; public static final int GAME_STATE = 3; public static final int SUBSCRIBE = 4; public static final int UNSUBSCRIBE = 5; public static final int HELLO = 6; public static final int VOTE_COLLECTION = 7; public static final int BACKUP_MESSAGE = 8; public static final int EMERGENCY_SUBSCRIBE = 9; private int type; private int messageID; private Object object; private RemoteSystem sender; public void setObject(Object j) { object = j; } public void setType(int t) { type = t; } public Object getObject() { return object; } public int getType() { return type; } public RemoteSystem getRemoteSystem() { return sender; } public void setRemoteSystem(RemoteSystem r) { sender=r; } public MessageObject() { messageID++; } public MessageObject(Object j, int t) { messageID++; object=j; type=t; } public MessageObject(Object j, int t, RemoteSystem rs) { messageID++; object=j; type=t; sender=rs; } public String toString() { String word; switch(type) { case 1: word="VOTE"; break; case 2: word="SUGGEST_PARENT"; break; case 3: word="GAME_STATE"; break; case 4: word="SUBSCRIBE"; break; case 5: word="UNSUBSCRIBE"; break; case 6: word="HELLO"; break; case 7: word="VOTE_COLLECTION"; break; default: word="UNKNOWN"; break; } return "MessageObject: " + word + " " + object; } }