Skip repeated SUBSCRIBE/UNSUBSCRIBE handling. #253

pull/282/head
Nikita 9 years ago
parent df928fe20f
commit ddf1eaa7c8

@ -199,7 +199,12 @@ public class CommandDecoder extends ReplayingDecoder<State> {
decode(in, data, respParts, channel, currentDecoder); decode(in, data, respParts, channel, currentDecoder);
} }
Object result = messageDecoder(data, respParts).decode(respParts, state()); MultiDecoder<Object> decoder = messageDecoder(data, respParts, channel);
if (decoder == null) {
return;
}
Object result = decoder.decode(respParts, state());
if (result instanceof Message) { if (result instanceof Message) {
handleMultiResult(data, null, channel, result); handleMultiResult(data, null, channel, result);
@ -258,13 +263,13 @@ public class CommandDecoder extends ReplayingDecoder<State> {
} }
} }
private MultiDecoder<Object> messageDecoder(CommandData<Object, Object> data, List<Object> parts) { private MultiDecoder<Object> messageDecoder(CommandData<Object, Object> data, List<Object> parts, Channel channel) {
if (data == null) { if (data == null) {
if (Arrays.asList("subscribe", "psubscribe", "punsubscribe", "unsubscribe").contains(parts.get(0))) { if (Arrays.asList("subscribe", "psubscribe", "punsubscribe", "unsubscribe").contains(parts.get(0))) {
String channelName = (String) parts.get(1); String channelName = (String) parts.get(1);
CommandData<Object, Object> commandData = channels.get(channelName); CommandData<Object, Object> commandData = channels.get(channelName);
if (commandData == null) { if (commandData == null) {
throw new IllegalStateException("Can't find CommandData for command: " + parts); return null;
} }
return commandData.getCommand().getReplayMultiDecoder(); return commandData.getCommand().getReplayMultiDecoder();
} else if (parts.get(0).equals("message")) { } else if (parts.get(0).equals("message")) {

Loading…
Cancel
Save