mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-27 00:32:07 +01: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:
parent
15c6d3d49b
commit
627b38fe5b
1 changed files with 16 additions and 3 deletions
|
@ -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.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue