Skip to content

Instantly share code, notes, and snippets.

@kitskub
Last active December 20, 2015 15:09
Show Gist options
  • Select an option

  • Save kitskub/6151864 to your computer and use it in GitHub Desktop.

Select an option

Save kitskub/6151864 to your computer and use it in GitHub Desktop.
if (dynamicPacketMap.getKeys().contains(clazz.getName())) {
// Already bound, just return
return dynamicPacketMap.register(clazz.getName());
}
if (dynamicId) {
int id;
do {
id = nextId.getAndIncrement();
} while (find(prevNewId) != null);
codec = constructor.newInstance(id);
codec.setDynamic(true);
} else {
//Codec is static
final MessageCodec<?> prevCodec = find(codec.getOpcode());
if (prevCodec != null) {
throw new IllegalStateException("Trying to register a static opcode where one already exists. Static:" + clazz.getSimpleName() + " Other:" + prevCodec.getClass().getSimpleName());
}
codec = constructor.newInstance();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment