generateCmdID
parent
c0dd200e24
commit
83dad1ba08
|
@ -3,7 +3,6 @@ package earth.krakatao;
|
|||
import earth.krakatao.events.KraSocketClientEventInitiater;
|
||||
import earth.krakatao.events.KraSocketClientEventInterface;
|
||||
import earth.krakatao.protocol.KraSocketClientProtocol;
|
||||
import earth.krakatao.protocol.KraSocketClientProtocolMessage;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.logging.Logger;
|
||||
|
|
|
@ -18,19 +18,20 @@ public class KraSocketClientProtocol {
|
|||
@Getter
|
||||
HashMap<Integer, Consumer<KraSocketClientProtocolMessage>> consumerHashMap = new HashMap<>();
|
||||
|
||||
public int getCmdID() {
|
||||
if (cmdIDs.isEmpty()) {
|
||||
cmdIDs.add(10);
|
||||
return 10;
|
||||
private int currentCmdIDIndex = 10;
|
||||
|
||||
public int generateCmdID() {
|
||||
// TODO: check max int value 2^32
|
||||
if (this.currentCmdIDIndex < 10 || this.currentCmdIDIndex > 15000) {
|
||||
this.currentCmdIDIndex = 10;
|
||||
return this.currentCmdIDIndex;
|
||||
}
|
||||
|
||||
int cmdID = cmdIDs.get(cmdIDs.size() - 1) + 1;
|
||||
this.currentCmdIDIndex++;
|
||||
|
||||
cmdIDs.add(cmdID);
|
||||
KraSocketClient.getLogger().info("currentCmdIDIndex:" + currentCmdIDIndex);
|
||||
|
||||
// TODO: check max int value 2^32
|
||||
|
||||
return cmdID;
|
||||
return this.currentCmdIDIndex;
|
||||
}
|
||||
|
||||
public byte[] EncodeMessage(KraSocketClientProtocolMessage kraProtocolMessage) {
|
||||
|
|
Loading…
Reference in New Issue