<html>
<xmp>
/**
 * Title: GPS Simulator
 * Copyright: Copyright (c) 2002
 * Company:   University of Oregon Computer Science Dept.
 *
 * @author Jason Prideaux
 * @version 1.0
 *
 */

package transport.protocol;

import java.io.*;


/* ====================================================================== */
/** This class represents a Multicast message.  This message is sent by
 *  agents to the simulator, the simulator then sends the message to all
 *  agents that are with within range and certain number of hops.  It is
 *  for when agents want to send messages to each other.
 *
 */
public abstract class P2PMessage extends Message implements Serializable{


	/** Content to send in this message. Must be Serializable. */
	private Object content;

	/** The maximum number hops the message can make. */
	private int hops;


    /* ===================================================================== */
    /** This constructor initializes the Message.  Object content must be added
     *  seperately with setContent() method, and the object must be
     *  Serializable.
     *
     *  @param  message   The String message.
     *  @param  from   The port the message sender listens to.
     *
     */
  	public P2PMessage(int from){
		super(2323, from);

		hops = 10;

	} //Constructor



    /* ===================================================================== */
    /** This constructor initializes the Message.  Object content must be added
     *  seperately with setContent() method, and the object must be
     *  Serializable.
     *
     *  @param  message   The String message.
     *  @param  from   The port the message sender listens to.
     *  @param  hops   The max number of hops.
     *
     */
  	public P2PMessage(int from, int hops){
		super(2323, from);

		this.hops = hops;

	} //Constructor




    /* ===================================================================== */
    /** This method returns the object content of the message.
     *
     *  @return  Object   The object content.
     *
     */
	public Object getContent(){

		return content;

	} //method: getContent


    /* ===================================================================== */
    /** This method sets the object data to send in this message.
     *
     *  @param  Object   The Serializable object to send.
     *
     */
	public void setContent(Object c){

		this.content = c;

	} //method: setContent


    /* ===================================================================== */
    /** This method returns the max number of hops for this message to take.
     *
     *  @return  int   The number of hops.
     *
     */
	public int getHops(){

		return hops;

	} //method: hops


} //class: P2PMessage
</xmp>
</html>

