public abstract class GenericPacket extends Object implements IPacket
| Modifier and Type | Field and Description |
|---|---|
protected byte |
flags
Packet header flags.
|
protected IPacketAddress |
from
Packet source address, if packet is received from net.
|
MQTT_CHARSET, pTYpeNames| Modifier | Constructor and Description |
|---|---|
protected |
GenericPacket()
Construct packet to be sent.
|
protected |
GenericPacket(IPacketAddress from)
Construct packet from network.
|
| Modifier and Type | Method and Description |
|---|---|
IPacket |
applyTTRs(Collection<TaggedTailRecord> ttrs)
Internal use only.
|
byte |
getFlags()
Get packet flags.
|
IPacketAddress |
getFrom()
Get packet sender address.
|
Optional<Integer> |
getPacketNumber() |
Optional<Integer> |
getReplyToPacketNumber() |
boolean |
isSigned()
Packet with valid signature?
|
static IPacket |
recv(DatagramSocket s)
Wait for packet to come in.
|
static DatagramSocket |
recvSocket()
Create new socket to listen to MQTT/UDP packets.
|
void |
send()
Broadcast me using default send socket.
|
void |
send(DatagramSocket sock)
Broadcast me using given socket.
|
void |
send(DatagramSocket sock,
InetAddress address)
Send me to given address.
|
void |
send(InetAddress addr)
Send me using default send socket.
|
void |
setPacketNumber(int packetNumber) |
void |
setReplyToPacketNumber(int replyToPacketNumber) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdecodeTopicLen, decodeTTRs, encodeTotalLength, encodeTTR, fromBytes, getPacketTypeName, getType, toBytesprotected byte flags
protected IPacketAddress from
protected GenericPacket(IPacketAddress from)
from - Sender's address.protected GenericPacket()
public static DatagramSocket recvSocket() throws SocketException
SocketException - If unable.public void send()
throws IOException
IOException - If unable.public void send(InetAddress addr) throws IOException
addr - Where to send to.IOException - If unable.public void send(DatagramSocket sock) throws IOException
sock - Socket must be made with sendSocket() method.IOException - If unable.public void send(DatagramSocket sock, InetAddress address) throws IOException
sock - Socket must be made with sendSocket() method.address - Host to send toIOException - If unable.public static IPacket recv(DatagramSocket s) throws IOException, MqttProtocolException
s - Socket to use.SocketException - As is.IOException - As is.MqttProtocolException - What we got is not a valid MQTT/UDP packet.public IPacketAddress getFrom()
IPacketpublic byte getFlags()
public IPacket applyTTRs(Collection<TaggedTailRecord> ttrs)
Internal use only.
Apply data from TTRs to constructed packet.
ttrs - Tagged Tail Records to applypublic void setReplyToPacketNumber(int replyToPacketNumber)
public void setPacketNumber(int packetNumber)
Copyright © 2019. All rights reserved.