Class Join
java.lang.Object
edu.uky.cs.nil.tt.io.Message
edu.uky.cs.nil.tt.io.Join
- All Implemented Interfaces:
Timestamped
-
Nested Class Summary
Nested classes/interfaces inherited from interface Timestamped
Timestamped.Adapter -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringThe new agent's namefinal StringThe name of the partner this new agent wants to play with, or null if they are willing to play with any partnerfinal StringThe new agent's password, which must be provided if the agent is using anamethat is reserved on this server, or which should be null if the agent is not using a reserved namefinal RoleThe role this new agent wants to have in their session, or null if they are willing to play either rolefinal StringThe name of the story world this new agent wants to play in, or null if they are willing to play in any story worldFields inherited from interface Timestamped
FORMAT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns true if this join request is compatible with another, meaning a session could be created between the agents who sent the messages.Returns a copy of this message with the agent's password removed.toString()voidverify()Checks that this message is correctly configured and throws an exception if not.Methods inherited from class Message
configure, getAgent, getTimestamp, setAgent
-
Field Details
-
name
The new agent's name -
password
-
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
The role this new agent wants to have in their session, or null if they are willing to play either role -
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
Constructs a new join message with an agent's credentials and preferences.- Parameters:
name- the new agent's namepassword- the new agent's password, or null if they are not using a reserved nameworld- the world the new agent wants to play in, or null if they have no preferencerole- the role the new agent wants to have, or null if they have no preferencepartner- the name of the partner this new agent wants to play with, or null if they have no preference
-
-
Method Details
-
toString
-
verify
public void verify()Description copied from class:MessageChecks 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. -
removePassword
Returns a copy of this message with the agent's password removed.- Returns:
- a copy of this message with no password
-
matches
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
-