Package marauroa.server.net.flood
Class FloodMeasure
java.lang.Object
marauroa.server.net.flood.FloodMeasure
Stores for each player the amount of messages and bytes sent since the last
timestamp.
- Author:
- miguel
-
Field Summary
Modifier and TypeFieldDescriptionThe socket channel associated.int
Store how many times it has caused a flood warning.long
The last timestamp when the flood was measured.int
The amount of bytes received from client since the timestampint
The amount of messages received from client since the timestamp. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMessage(int length)
Add a new message to the measure.int
Return the amount of bytes per second the client sent.int
Return the amount of messages per second the client sent.int
Return the amount of warnings done because of flood.void
Clears the flood measurement and reset the timestamp.void
Reset the number of warnings because of flood.int
Return the number of seconds since the last reset.toString()
void
warning()
Adds a new flood warning to the measurement.
-
Field Details
-
channel
The socket channel associated. -
lasttimestamp
public long lasttimestampThe last timestamp when the flood was measured. -
sendMessages
public int sendMessagesThe amount of messages received from client since the timestamp. -
sendBytes
public int sendBytesThe amount of bytes received from client since the timestamp -
floodWarnings
public int floodWarningsStore how many times it has caused a flood warning.
-
-
Constructor Details
-
FloodMeasure
Constructor- Parameters:
channel
- the associated resource to this measure object.
-
-
Method Details
-
resetPerSecondData
public void resetPerSecondData()Clears the flood measurement and reset the timestamp. -
addMessage
public void addMessage(int length)Add a new message to the measure.- Parameters:
length
-
-
warning
public void warning()Adds a new flood warning to the measurement. -
getBytesPerSecond
public int getBytesPerSecond()Return the amount of bytes per second the client sent.- Returns:
- the amount of bytes per second the client sent.
-
getMessagesPerSecond
public int getMessagesPerSecond()Return the amount of messages per second the client sent.- Returns:
- the amount of messages per second the client sent.
-
getWarnings
public int getWarnings()Return the amount of warnings done because of flood.- Returns:
- the amount of warnings done because of flood.
-
sinceLastReset
public int sinceLastReset()Return the number of seconds since the last reset.- Returns:
- the number of seconds since the last reset.
-
resetWarnings
public void resetWarnings()Reset the number of warnings because of flood. -
toString
-