generateCmdID
parent
c0dd200e24
commit
83dad1ba08
|
@ -3,7 +3,6 @@ package earth.krakatao;
|
||||||
import earth.krakatao.events.KraSocketClientEventInitiater;
|
import earth.krakatao.events.KraSocketClientEventInitiater;
|
||||||
import earth.krakatao.events.KraSocketClientEventInterface;
|
import earth.krakatao.events.KraSocketClientEventInterface;
|
||||||
import earth.krakatao.protocol.KraSocketClientProtocol;
|
import earth.krakatao.protocol.KraSocketClientProtocol;
|
||||||
import earth.krakatao.protocol.KraSocketClientProtocolMessage;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
|
@ -18,19 +18,20 @@ public class KraSocketClientProtocol {
|
||||||
@Getter
|
@Getter
|
||||||
HashMap<Integer, Consumer<KraSocketClientProtocolMessage>> consumerHashMap = new HashMap<>();
|
HashMap<Integer, Consumer<KraSocketClientProtocolMessage>> consumerHashMap = new HashMap<>();
|
||||||
|
|
||||||
public int getCmdID() {
|
private int currentCmdIDIndex = 10;
|
||||||
if (cmdIDs.isEmpty()) {
|
|
||||||
cmdIDs.add(10);
|
public int generateCmdID() {
|
||||||
return 10;
|
// 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 this.currentCmdIDIndex;
|
||||||
|
|
||||||
return cmdID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] EncodeMessage(KraSocketClientProtocolMessage kraProtocolMessage) {
|
public byte[] EncodeMessage(KraSocketClientProtocolMessage kraProtocolMessage) {
|
||||||
|
|
Loading…
Reference in New Issue