public class ClientConnection extends Connection implements GameStateListener
Modifier and Type | Field and Description |
---|---|
private PacketPlayerJoinReject.RejectReason |
failReason
The reason a server connection could not be established (if any).
|
private Player |
self
The local player that wants to join.
|
Modifier | Constructor and Description |
---|---|
private |
ClientConnection(java.net.Socket socket,
Player self)
Constructs a new client connection from the given socket
connection and with the given local player.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Called when the game is aborted (forcefully terminated).
|
void |
claim(Player player,
ConvexObject obj)
Called when a player claims a new object.
|
static ClientConnection |
connect(java.lang.String host,
Player player)
Attempts to establish a new multiplayer connection
to the given host and with the given local player.
|
void |
end()
Called when the game ends.
|
GameState |
getGameState()
Gets the gamestate for the remote game.
|
PacketPlayerJoinReject.RejectReason |
getRejectReason()
Gets the reason why the connection to the server failed (if any).
|
boolean |
isConnected()
Checks if this client was connected to the server.
|
void |
merge(Player player,
ConvexObject source,
ConvexObject target,
ConvexObject result,
java.util.List<ConvexObject> absorbed)
Called when a player performs a merge.
|
close, isClosed, readPacket, sendPacket
private Player self
private PacketPlayerJoinReject.RejectReason failReason
private ClientConnection(java.net.Socket socket, Player self) throws java.io.IOException
socket
- The server connection.self
- The local player instance.java.io.IOException
- When an IOException occurs.public boolean isConnected()
public PacketPlayerJoinReject.RejectReason getRejectReason()
public GameState getGameState() throws java.io.IOException
java.io.IOException
- When an IOException occurs.public void claim(Player player, ConvexObject obj)
GameStateListener
claim
in interface GameStateListener
player
- The player that made the claim.obj
- The object that was claimed.public void merge(Player player, ConvexObject source, ConvexObject target, ConvexObject result, java.util.List<ConvexObject> absorbed)
GameStateListener
merge
in interface GameStateListener
player
- The player that performed the merge.source
- The object the merge was started from.target
- The target object of the merge.result
- The object resulting from the merge.absorbed
- The objects absorbed in the merge.public void end()
GameStateListener
end
in interface GameStateListener
public void abort()
GameStateListener
abort
in interface GameStateListener
public static final ClientConnection connect(java.lang.String host, Player player) throws java.io.IOException
host
- The host to connect to.player
- The local player joining.java.io.IOException
- When an IOException occured.