Skip to content

Instantly share code, notes, and snippets.

@volgar1x
Created April 12, 2014 16:02
Show Gist options
  • Save volgar1x/10543083 to your computer and use it in GitHub Desktop.
Save volgar1x/10543083 to your computer and use it in GitHub Desktop.
err.visit(AuthError.<NetworkCommand>visitor()
.alreadyConnected(it -> client.write(new IdentificationFailedMessage(
(byte) IdentificationFailureReasonEnum.TOO_MANY_ON_IP.value)))
.banned(it -> client.write(new IdentificationFailedBannedMessage(
(byte) IdentificationFailureReasonEnum.BANNED.value,
it.getEnd().toEpochMilli())))
.wrongCredentials(it -> client.write(new IdentificationFailedMessage(
(byte) IdentificationFailureReasonEnum.WRONG_CREDENTIALS.value)))
.otherwise(it -> client.write(new IdentificationFailedMessage(
(byte) IdentificationFailureReasonEnum.UNKNOWN_AUTH_ERROR.value)))
.build())
.reduce(NetworkCommand::then)
.ifPresent(NetworkCommand::async);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment