Class Stop


public class Stop extends Message
The stop message can be sent from either the {edu.uky.cs.nil.tt.Server server} or the agent to indicate that no more turns will happen in the session (though reports may still happen) and that the session should end soon.

An agent can send the stop message (1) if they want to stop a session early before the story had reached one of its defined endings, or (2) to indicate they are finished and have no more reports to send. After an agent sends the stop message, they may not send any more messages (including reports), though they may stay connected to wait for the end message.

The server will send the stop message to notify both agents that no more turns can be taken. This will happen when (1) the story reaches one of its defined endings, (2) one of the agents in the session stops it early, (3) one of the agents in the session disconnects, or (4) the server shuts down.

Once an agent receives the stop message, it cannot take any more turns, even if the story has not reached one of its defined endings. However, an agent may still send reports. When an agent is done sending reports, it should send a stop message to indicate this.

After both agents have either sent stop messages or disconnected, the end message will be sent to both agents.

Author:
Stephen G. Ware
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Ending
    One of the pre-defined endings from the story world, or null if this session did not reach one of those endings
    final String
    A message explaining how the session ended
    final Role
    The participant who ended the session, or null if the session reached a pre-defined ending or was ended by the server
  • Constructor Summary

    Constructors
    Constructor
    Description
    Stop(Role role)
    Constructs a stop message for the role who stopped the session before it reached a pre-defined ending.
    Stop(Ending ending)
    Constructs a stop message from a pre-defined story ending.
    Stop(String message)
    Constructs a stop message with a string explaining how the session ended before it reached a pre-definded ending.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    void
    Checks that this message is correctly configured and throws an exception if not.

    Methods inherited from class Message

    configure, getAgent, setAgent

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ending

      public final Ending ending
      One of the pre-defined endings from the story world, or null if this session did not reach one of those endings
    • role

      public final Role role
      The participant who ended the session, or null if the session reached a pre-defined ending or was ended by the server
    • message

      public final String message
      A message explaining how the session ended
  • Constructor Details

    • Stop

      public Stop(Ending ending)
      Constructs a stop message from a pre-defined story ending.
      Parameters:
      ending - the pre-defined ending that occurred in the story
    • Stop

      public Stop(Role role)
      Constructs a stop message for the role who stopped the session before it reached a pre-defined ending.
      Parameters:
      role - the role who stopped the story
    • Stop

      public Stop(String message)
      Constructs a stop message with a string explaining how the session ended before it reached a pre-definded ending.
      Parameters:
      message - a string explaining why the session ended
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • verify

      public void verify()
      Description copied from class: Message
      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.
      Specified by:
      verify in class Message