Class PlayerNode.Remote
java.lang.Object
org.xxdc.oss.example.PlayerNode.Remote
- All Implemented Interfaces:
AutoCloseable,ToIntFunction<GameState>,PlayerNode
- Enclosing interface:
PlayerNode
Represents a remote player node that communicates with a client over a transport server. The
remote player node sends the current game state to the client and receives the player's next
move. The remote player node is responsible for validating the received move and applying it to
the game board. The remote player node must be closed when the game is finished to release the
transport server resources.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.xxdc.oss.example.PlayerNode
PlayerNode.Local<P extends Player>, PlayerNode.Remote -
Constructor Summary
ConstructorsConstructorDescriptionRemote(String playerMarker, TransportServer transport) Constructs a new Remote PlayerNode instance that communicates with a client over the provided TransportServer. -
Method Summary
Modifier and TypeMethodDescriptionintapplyAsInt(GameState state) Gets the player's next move to apply to the given game board.voidclose()Gets the player's marker: a string representation of the player's identity.toString()
-
Constructor Details
-
Remote
Constructs a new Remote PlayerNode instance that communicates with a client over the provided TransportServer.- Parameters:
playerMarker- the marker to identify this playertransport- the TransportServer to use for communication with the client- Throws:
IllegalArgumentException- if the provided TransportServer is null
-
-
Method Details
-
applyAsInt
Gets the player's next move to apply to the given game board.- Specified by:
applyAsIntin interfacePlayerNode- Specified by:
applyAsIntin interfaceToIntFunction<GameState>- Parameters:
state- the current state of the game- Returns:
- the location on the game board where the move was made
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
playerMarker
Description copied from interface:PlayerNodeGets the player's marker: a string representation of the player's identity. Returns the marker (e.g. "X" or "O") used by this player.- Specified by:
playerMarkerin interfacePlayerNode- Returns:
- the player's marker
-
toString
-