Class Message

java.lang.Object
edu.uky.cs.nil.tt.io.Message
Direct Known Subclasses:
Choice, Connect, End, Error, Join, Report, Start, Stop, Update

public abstract class Message extends Object
A message is information sent to or from a server in JSON format.
Author:
Stephen G. Ware
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a message.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    configure(com.google.gson.GsonBuilder builder)
    Configures a GsonBuilder to encode and decode Message objects as JSON.
    Returns the Agent who sent this message, or null if this message was sent by the server.
    void
    setAgent(Agent agent)
    Sets the Agent who sent this message.
    abstract void
    Checks that this message is correctly configured and throws an exception if not.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Message

      public Message()
      Constructs a message.
  • Method Details

    • configure

      public static void configure(com.google.gson.GsonBuilder builder)
      Configures a GsonBuilder to encode and decode Message objects as JSON.
      Parameters:
      builder - the GSON builder to configure
    • getAgent

      public Agent getAgent()
      Returns the Agent who sent this message, or null if this message was sent by the server.
      Returns:
      the agent who sent the message, or null
    • setAgent

      public void setAgent(Agent agent)
      Sets the Agent who sent this message. For messages sent to the server, this method should be called soon after the message has been parsed.
      Parameters:
      agent - the agent who sent this message
    • verify

      public abstract void verify()
      Checks that this message is correctly configured and throws an exception if not. This method should be called soon after the message has been parsed. It should check that all the necessary fields are set and that their values are legal values.