1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-06-18 01:14:50 +02:00

Handles packets with no (explicit) id

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2223 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2004-02-10 15:36:57 +00:00 committed by gdombiak
parent 15c6d3d49b
commit 627b38fe5b

View file

@ -71,6 +71,13 @@ import java.io.*;
*/ */
public abstract class Packet { public abstract class Packet {
/**
* Constant used as packetID to indicate that a packet has no id. To indicate that a packet
* has no id set this constant as the packet's id. When the packet is asked for its id the
* answer will be <tt>null</tt>.
*/
public static final String ID_NOT_AVAILABLE = "ID_NOT_AVAILABLE";
/** /**
* A prefix helps to make sure that ID's are unique across mutliple instances. * A prefix helps to make sure that ID's are unique across mutliple instances.
*/ */
@ -100,11 +107,16 @@ public abstract class Packet {
private XMPPError error = null; private XMPPError error = null;
/** /**
* Returns the unique ID of the packet. * Returns the unique ID of the packet. The returned value could be <tt>null</tt> when
* ID_NOT_AVAILABLE was set as the packet's id.
* *
* @return the packet's unique ID. * @return the packet's unique ID or <tt>null</tt> if the packet's id is not available.
*/ */
public String getPacketID() { public String getPacketID() {
if (ID_NOT_AVAILABLE.equals(packetID)) {
return null;
}
if (packetID == null) { if (packetID == null) {
packetID = nextID(); packetID = nextID();
} }
@ -112,7 +124,8 @@ public abstract class Packet {
} }
/** /**
* Sets the unique ID of the packet. * Sets the unique ID of the packet. To indicate that a packet has no id
* pass the constant ID_NOT_AVAILABLE as the packet's id value.
* *
* @param packetID the unique ID for the packet. * @param packetID the unique ID for the packet.
*/ */