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
FieldsModifier and TypeFieldDescriptionThe socket channel associated.intStore how many times it has caused a flood warning.longThe last timestamp when the flood was measured.intThe amount of bytes received from client since the timestampintThe amount of messages received from client since the timestamp. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(int length)Add a new message to the measure.intReturn the amount of bytes per second the client sent.intReturn the amount of messages per second the client sent.intReturn the amount of warnings done because of flood.voidClears the flood measurement and reset the timestamp.voidReset the number of warnings because of flood.intReturn the number of seconds since the last reset.toString()voidwarning()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
-