Class PlayerEntry

java.lang.Object
marauroa.server.game.container.PlayerEntry

public class PlayerEntry extends Object
This class represent a player on game. It handles all the business glue that it is needed by the server.
Author:
miguel
  • Field Details

    • creationTime

      public long creationTime
      We record when this player entry was created to remove players that don't complete login stage but that keep connected.
    • state

      public ClientState state
      The state in which this player is
    • clientid

      public int clientid
      The runtime clientid
    • channel

      public Channel channel
      The client associated SocketChannel
    • loginInformations

      public SecuredLoginInfo loginInformations
      The login Info. It is created after the first login message and destroyed after the login is finished.
    • username

      public String username
      The name of the player
    • character

      public String character
      The name of the chosen character
    • object

      public RPObject object
      The object of the player
    • locale

      public Locale locale
      client locale
    • activityTimestamp

      public long activityTimestamp
      We need to control if player is active because sometimes server changes its IP and we are not able to realize about this at server side, so all the clients are left there until the TCP stack determine a timeout that can be a long time.
    • perceptionCounter

      public int perceptionCounter
      A counter to detect dropped packets or bad order at client side. We enumerate each perception so client can know in which order it is expected to apply them. When using TCP there is no problem as delivery is guaranteed.
    • requestedSync

      public boolean requestedSync
      It is true if client notified us that it got out of sync
    • contentToTransfer

      public List<TransferContent> contentToTransfer
      Contains the content that is going to be transfered to client
    • characterCounter

      public int characterCounter
      the number of characters owned by this account
  • Constructor Details

    • PlayerEntry

      public PlayerEntry(Channel channel)
      Constructor
      Parameters:
      channel - the socket channel
  • Method Details

    • getAddress

      public InetAddress getAddress()
      Return the inet address of this PlayerEntry.
      Returns:
      the inet address of this PlayerEntry.
    • getInetSocketAddress

      public InetSocketAddress getInetSocketAddress()
      Return the inet address of this PlayerEntry.
      Returns:
      the inet address of this PlayerEntry.
    • isTimeout

      public boolean isTimeout()
      Returns true when nothing has been received from client in TIMEOUT_SECONDS. Note that client sends confirmations to perceptions, so this mean that client is for whatever reason not working.
      Returns:
      true when nothing has been received from client in TIMEOUT_SECONDS.
    • disableTimeout

      public void disableTimeout()
      disables the timeout check (because it is done elsewhere)
    • update

      public void update()
      Refresh player timeout timestamp. This method is invoked when a new message arrives from client.
    • getPerceptionTimestamp

      public int getPerceptionTimestamp()
      Returns the next perception timestamp.
      Returns:
      the next perception timestamp
    • getThisPerceptionTimestamp

      public int getThisPerceptionTimestamp()
      returns the current perception timestamp
      Returns:
      the current perception timestamp
    • removeContent

      public void removeContent(TransferContent content)
      Clears the specified content to be transfered
      Parameters:
      content - TransferContent to remove from the queue
    • getContent

      public TransferContent getContent(String name)
      Returns the named content or returns null if it is not found.
      Parameters:
      name - name of the content to find
      Returns:
      the content or null if it is not found.
    • storeRPObject

      public void storeRPObject(RPObject player) throws SQLException, IOException
      This method stores an object at database backend
      Parameters:
      player - the object to store
      Throws:
      SQLException - in case of an database error
      IOException - in case of an input/output error
    • setObject

      public void setObject(RPObject object)
      sets the RPObject for this entry.
      Parameters:
      object - RPObject
    • requestSync

      public void requestSync()
      This method forces an update on the next perception sending.
    • getProtocolVersion

      public int getProtocolVersion()
      gets the version of the protocol this clients speaks
      Returns:
      protocolVersion
    • setProtocolVersion

      public void setProtocolVersion(int protocolVersion)
      sets the protocol version
      Parameters:
      protocolVersion - protocol version
    • toString

      public String toString()
      Overrides:
      toString in class Object