Added trivial messageID generator on client side
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
package org.dna.mqtt.commons;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author andrea
|
||||||
|
*/
|
||||||
|
public class MessageIDGenerator {
|
||||||
|
private AtomicInteger m_current;
|
||||||
|
|
||||||
|
public MessageIDGenerator() {
|
||||||
|
//NB we start at -1 because the first incAndGet has to return 0
|
||||||
|
m_current = new AtomicInteger(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int next() {
|
||||||
|
return m_current.incrementAndGet();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user