Class UdpMessage

java.lang.Object
org.somda.sdc.dpws.udp.UdpMessage

public class UdpMessage extends Object
Raw UDP message packed as a byte array plus a length attribute and receiver information.
  • Constructor Details

    • UdpMessage

      public UdpMessage(byte[] data, int length, CommunicationContext communicationContext)
      Constructor with transport information.
      Parameters:
      data - the payload of the UDP message.
      length - the actual message length.
      communicationContext - message transport and application information.
    • UdpMessage

      public UdpMessage(byte[] data, int length)
      Constructor without transport information.

      Transport information is not required in case this message is used with multicast.

      Parameters:
      data - the payload of the UDP message.
      length - the actual message length.
  • Method Details

    • hasTransportData

      public boolean hasTransportData()
      Checks if there is transport data attached to the message.
      Returns:
      true if there is a host and port, otherwise false.
    • getPort

      public Integer getPort()
    • getHost

      public String getHost()
    • getLength

      public int getLength()
    • getData

      public byte[] getData()
      Gets the data from this object as byte array.

      Do not rely on the byte array's length attribute, retrieve the length via getLength() instead!

      Returns:
      message byte array.
    • getCommunicationContext

      public CommunicationContext getCommunicationContext()
      Returns the communication context stored in this message.
      Returns:
      communication context containing transport information and more.
    • toString

      public String toString()
      Overrides:
      toString in class Object