Class FloodMeasure

java.lang.Object
marauroa.server.net.flood.FloodMeasure

public class FloodMeasure extends Object
Stores for each player the amount of messages and bytes sent since the last timestamp.
Author:
miguel
  • Field Details

    • channel

      public Channel channel
      The socket channel associated.
    • lasttimestamp

      public long lasttimestamp
      The last timestamp when the flood was measured.
    • sendMessages

      public int sendMessages
      The amount of messages received from client since the timestamp.
    • sendBytes

      public int sendBytes
      The amount of bytes received from client since the timestamp
    • floodWarnings

      public int floodWarnings
      Store how many times it has caused a flood warning.
  • Constructor Details

    • FloodMeasure

      public FloodMeasure(Channel channel)
      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

      public String toString()
      Overrides:
      toString in class Object