jfreerails.world.player
Class Player

java.lang.Object
  extended by jfreerails.world.player.Player
All Implemented Interfaces:
java.io.Serializable, FreerailsSerializable

public class Player
extends java.lang.Object
implements FreerailsSerializable

Represents a player within the game. The player model is such that a user can start a client, create a new player on the server and start playing. They can disconnect from the server, which may continue running with other players still active. The server can then save the list of players and be stopped and restarted again, the clients can then authenticate themselves to the server and continue their sessions where they left off. XXX the player is only authenticated when the connection is opened, and subsequent exchanges are not authenticated. TODO implement a more complete authentication system using certificates rather than public keys.

Author:
rtuck99@users.sourceforge.net
See Also:
Serialized Form

Nested Class Summary
private static class Player.WorldPrincipal
          A FreerailsPrincipal that is not a player.
 
Field Summary
static FreerailsPrincipal AUTHORITATIVE
          This Principal can be granted all permissions.
private  java.lang.String name
          Name of the player.
static FreerailsPrincipal NOBODY
          This Principal has no permissions.
private  FreerailsPrincipal principal
           
private static long serialVersionUID
           
 
Constructor Summary
Player(java.lang.String name)
          Used by the client to generate a player with a particular name.
Player(java.lang.String name, int id)
          Used by the server to generate a player with a particular name and public key.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.String getName()
           
 FreerailsPrincipal getPrincipal()
           
 int hashCode()
           
 void loadSession(java.io.ObjectInputStream in)
          Called by the client to reconstitute the data from a saved game.
 void saveSession(java.io.ObjectOutputStream out)
          TODO save this player's private data so that they can be re-connected to the server at a later point in time.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

principal

private FreerailsPrincipal principal

AUTHORITATIVE

public static final FreerailsPrincipal AUTHORITATIVE
This Principal can be granted all permissions.


NOBODY

public static final FreerailsPrincipal NOBODY
This Principal has no permissions.


name

private final java.lang.String name
Name of the player.

Constructor Detail

Player

public Player(java.lang.String name)
Used by the client to generate a player with a particular name.


Player

public Player(java.lang.String name,
              int id)
Used by the server to generate a player with a particular name and public key.

Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getName

public java.lang.String getName()

saveSession

public void saveSession(java.io.ObjectOutputStream out)
                 throws java.io.IOException
TODO save this player's private data so that they can be re-connected to the server at a later point in time.

Throws:
java.io.IOException

loadSession

public void loadSession(java.io.ObjectInputStream in)
                 throws java.io.IOException
Called by the client to reconstitute the data from a saved game.

Throws:
java.io.IOException

getPrincipal

public FreerailsPrincipal getPrincipal()