mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
Lazy load packet id.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1903 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
7b02479f66
commit
dd84663869
1 changed files with 5 additions and 2 deletions
|
@ -74,7 +74,7 @@ public abstract class Packet {
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
private static String prefix = StringUtils.randomString(5);
|
private static String prefix = StringUtils.randomString(5) + "-";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track of the current increment, which is appended to the prefix to
|
* Keeps track of the current increment, which is appended to the prefix to
|
||||||
|
@ -92,7 +92,7 @@ public abstract class Packet {
|
||||||
return prefix + Long.toString(id++);
|
return prefix + Long.toString(id++);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String packetID = nextID();
|
private String packetID = null;
|
||||||
private String to = null;
|
private String to = null;
|
||||||
private String from = null;
|
private String from = null;
|
||||||
private Map properties = null;
|
private Map properties = null;
|
||||||
|
@ -104,6 +104,9 @@ public abstract class Packet {
|
||||||
* @return the packet's unique ID.
|
* @return the packet's unique ID.
|
||||||
*/
|
*/
|
||||||
public String getPacketID() {
|
public String getPacketID() {
|
||||||
|
if (packetID == null) {
|
||||||
|
packetID = nextID();
|
||||||
|
}
|
||||||
return packetID;
|
return packetID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue