Package marauroa.server.game.container
Class PlayerEntry
java.lang.Object
marauroa.server.game.container.PlayerEntry
This class represent a player on game. It handles all the business glue that
it is needed by the server.
- Author:
- miguel
-
Field Summary
Modifier and TypeFieldDescriptionlong
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.The client associated SocketChannelThe name of the chosen characterint
the number of characters owned by this accountint
The runtime clientidContains the content that is going to be transfered to clientlong
We record when this player entry was created to remove players that don't complete login stage but that keep connected.client localeThe login Info.The object of the playerint
A counter to detect dropped packets or bad order at client side.boolean
It is true if client notified us that it got out of syncThe state in which this player isThe name of the player -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
disables the timeout check (because it is done elsewhere)Return the inet address of this PlayerEntry.getContent(String name)
Returns the named content or returns null if it is not found.Return the inet address of this PlayerEntry.int
Returns the next perception timestamp.int
gets the version of the protocol this clients speaksint
returns the current perception timestampboolean
Returns true when nothing has been received from client in TIMEOUT_SECONDS.void
removeContent(TransferContent content)
Clears the specified content to be transferedvoid
This method forces an update on the next perception sending.void
sets the RPObject for this entry.void
setProtocolVersion(int protocolVersion)
sets the protocol versionvoid
storeRPObject(RPObject player)
This method stores an object at database backendtoString()
void
update()
Refresh player timeout timestamp.
-
Field Details
-
creationTime
public long creationTimeWe record when this player entry was created to remove players that don't complete login stage but that keep connected. -
state
The state in which this player is -
clientid
public int clientidThe runtime clientid -
channel
The client associated SocketChannel -
loginInformations
The login Info. It is created after the first login message and destroyed after the login is finished. -
username
The name of the player -
character
The name of the chosen character -
object
The object of the player -
locale
client locale -
activityTimestamp
public long activityTimestampWe 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 perceptionCounterA 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 requestedSyncIt is true if client notified us that it got out of sync -
contentToTransfer
Contains the content that is going to be transfered to client -
characterCounter
public int characterCounterthe number of characters owned by this account
-
-
Constructor Details
-
PlayerEntry
Constructor- Parameters:
channel
- the socket channel
-
-
Method Details
-
getAddress
Return the inet address of this PlayerEntry.- Returns:
- the inet address of this PlayerEntry.
-
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
Clears the specified content to be transfered- Parameters:
content
- TransferContent to remove from the queue
-
getContent
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
This method stores an object at database backend- Parameters:
player
- the object to store- Throws:
SQLException
- in case of an database errorIOException
- in case of an input/output error
-
setObject
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
-