Parse CloseConnectionDuplicateClientName without identifier
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 10 Jul 2015 12:20:39 +0000 (14:20 +0200)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Fri, 10 Jul 2015 12:20:39 +0000 (14:20 +0200)
src/main/java/net/pterodactylus/fcp/quelaton/FcpReplySequence.java

index afaac4c..2c2dfe1 100644 (file)
@@ -126,11 +126,15 @@ public abstract class FcpReplySequence<R> implements AutoCloseable, FcpListener
        private <M extends BaseMessage> void consume(Consumer<M> consumer, M message,
                        String identifier) {
                if (Objects.equals(message.getField(identifier), this.identifier.get())) {
-                       consumer.accept(message);
-                       notifySyncObject();
+                       consumeAlways(consumer, message);
                }
        }
 
+       private <M extends BaseMessage> void consumeAlways(Consumer<M> consumer, M message) {
+               consumer.accept(message);
+               notifySyncObject();
+       }
+
        private void consumeUnknown(FcpMessage fcpMessage) {
                if (Objects.equals(fcpMessage.getField("Identifier"), identifier.get())) {
                        consumeUnknownMessage(fcpMessage);
@@ -153,7 +157,7 @@ public abstract class FcpReplySequence<R> implements AutoCloseable, FcpListener
        @Override
        public final void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection,
                        CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) {
-               consume(this::consumeCloseConnectionDuplicateClientName, closeConnectionDuplicateClientName);
+               consumeAlways(this::consumeCloseConnectionDuplicateClientName, closeConnectionDuplicateClientName);
        }
 
        protected void consumeCloseConnectionDuplicateClientName(CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) { }