Package org.somda.sdc.dpws.udp
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 Summary
Constructors Constructor Description UdpMessage(byte[] data, int length)Constructor without transport information.UdpMessage(byte[] data, int length, CommunicationContext communicationContext)Constructor with transport information.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommunicationContextgetCommunicationContext()Returns the communication context stored in this message.byte[]getData()Gets the data from this object as byte array.StringgetHost()intgetLength()IntegergetPort()booleanhasTransportData()Checks if there is transport data attached to the message.StringtoString()
-
-
-
Constructor Detail
-
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 Detail
-
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.
-
-