Class Join


public class Join extends Message
The join message is the first message sent from an agent to the {edu.uky.cs.nil.tt.Server server} to provide the agent's credentials and its preferences for what story world, role, and partner they want for their session.
Author:
Stephen G. Ware
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final String
    The new agent's name
    final String
    The name of the partner this new agent wants to play with, or null if they are willing to play with any partner
    final String
    The new agent's password, which must be provided if the agent is using a name that is reserved on this server, or which should be null if the agent is not using a reserved name
    final Role
    The role this new agent wants to have in their session, or null if they are willing to play either role
    final String
    The name of the story world this new agent wants to play in, or null if they are willing to play in any story world
  • Constructor Summary

    Constructors
    Constructor
    Description
    Join(String name, String password, String world, Role role, String partner)
    Constructs a new join message with an agent's credentials and preferences.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    matches(Join other)
    Returns true if this join request is compatible with another, meaning a session could be created between the agents who sent the messages.
     
    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

    • name

      public final String name
      The new agent's name
    • password

      public final String password
      The new agent's password, which must be provided if the agent is using a name that is reserved on this server, or which should be null if the agent is not using a reserved name
    • world

      public final String world
      The name of the story world this new agent wants to play in, or null if they are willing to play in any story world
    • role

      public final Role role
      The role this new agent wants to have in their session, or null if they are willing to play either role
    • partner

      public final String partner
      The name of the partner this new agent wants to play with, or null if they are willing to play with any partner
  • Constructor Details

    • Join

      public Join(String name, String password, String world, Role role, String partner)
      Constructs a new join message with an agent's credentials and preferences.
      Parameters:
      name - the new agent's name
      password - the new agent's password, or null if they are not using a reserved name
      world - the world the new agent wants to play in, or null if they have no preference
      role - the role the new agent wants to have, or null if they have no preference
      partner - the name of the partner this new agent wants to play with, or null if they have no preference
  • 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
    • matches

      public boolean matches(Join other)
      Returns true if this join request is compatible with another, meaning a session could be created between the agents who sent the messages. This method will not match two requests which both specify no preference for a partner. In other words, at least one of the requests must specify a partner.
      Parameters:
      other - the join message of another agent waiting for a session
      Returns:
      true if the join messages are compatible, or false if they are not compatible