Class UdpMessage

java.lang.Object
org.microproxy.udp.UdpMessage

public final class UdpMessage extends Object
One datagram's payload in a UDP flow the proxy relays, as a UdpInterceptor sees it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UdpMessage(byte[] data, boolean fromClient, Instant timestamp)
    A message.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    The payload as received.
    boolean
    Returns whether the client sent the datagram (going to the target), rather than the target.
    int
    Returns the number of bytes.
    The payload decoded as UTF-8, malformed sequences replaced with U+FFFD.
    Returns when the proxy received the datagram.
     
    withData(byte[] data)
    A copy of this message with another payload, the same direction and timestamp.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • UdpMessage

      public UdpMessage(byte[] data, boolean fromClient, Instant timestamp)
      A message.
      Parameters:
      data - the payload, which the message holds as it is (not copied)
      fromClient - whether the client sent it, rather than the target
      timestamp - when the proxy received it
  • Method Details

    • data

      public byte[] data()
      The payload as received. The array is the message's own, not a copy: an interceptor may change it in place and return it.
      Returns:
      the payload
    • length

      public int length()
      Returns the number of bytes.
      Returns:
      the number of bytes
    • fromClient

      public boolean fromClient()
      Returns whether the client sent the datagram (going to the target), rather than the target.
      Returns:
      whether the client sent the datagram (going to the target), rather than the target
    • timestamp

      public Instant timestamp()
      Returns when the proxy received the datagram.
      Returns:
      when the proxy received the datagram
    • text

      public String text()
      The payload decoded as UTF-8, malformed sequences replaced with U+FFFD.
      Returns:
      the text
    • withData

      public UdpMessage withData(byte[] data)
      A copy of this message with another payload, the same direction and timestamp.
      Parameters:
      data - the payload of the copy (not copied)
      Returns:
      the copy
    • toString

      public String toString()
      Overrides:
      toString in class Object