use of org.redisson.client.ChannelName in project redisson by redisson.
the class RedissonReactiveSubscription method pUnsubscribe.
@Override
public Mono<Void> pUnsubscribe(ByteBuffer... patterns) {
monosListener.acquire();
return Mono.defer(() -> {
List<CompletableFuture<?>> futures = new ArrayList<>(patterns.length);
for (ByteBuffer channel : patterns) {
ChannelName cn = toChannelName(channel);
CompletableFuture<Codec> f = subscribeService.unsubscribe(cn, PubSubType.PUNSUBSCRIBE);
f = f.whenComplete((res, e) -> {
synchronized (RedissonReactiveSubscription.this.patterns) {
Collection<PubSubConnectionEntry> entries = RedissonReactiveSubscription.this.patterns.get(cn);
entries.stream().filter(en -> en.hasListeners(cn)).forEach(ee -> RedissonReactiveSubscription.this.patterns.remove(cn));
}
});
futures.add(f);
}
CompletableFuture<Void> future = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
future = future.whenComplete((r, e) -> {
monosListener.release();
});
return Mono.fromFuture(future);
});
}
use of org.redisson.client.ChannelName in project redisson by redisson.
the class CommandPubSubDecoder method messageDecoder.
@Override
protected MultiDecoder<Object> messageDecoder(CommandData<Object, Object> data, List<Object> parts) {
if (parts.isEmpty() || parts.get(0) == null) {
return null;
}
String command = parts.get(0).toString();
if (MESSAGES.contains(command)) {
ChannelName channelName = new ChannelName((byte[]) parts.get(1));
PubSubKey key = new PubSubKey(channelName, command);
CommandData<Object, Object> commandData = commands.get(key);
if (commandData == null) {
return null;
}
return commandData.getCommand().getReplayMultiDecoder();
} else if ("message".equals(command)) {
byte[] channelName = (byte[]) parts.get(1);
PubSubEntry entry = entries.get(new ChannelName(channelName));
if (entry == null) {
return null;
}
return entry.getDecoder();
} else if ("pmessage".equals(command)) {
byte[] patternName = (byte[]) parts.get(1);
PubSubEntry entry = entries.get(new ChannelName(patternName));
if (entry == null) {
return null;
}
return entry.getDecoder();
} else if ("pong".equals(command)) {
return new ListObjectDecoder<>(0);
}
return data.getCommand().getReplayMultiDecoder();
}
use of org.redisson.client.ChannelName in project redisson by redisson.
the class PubSubPatternMessageDecoder method decode.
@Override
public PubSubPatternMessage decode(List<Object> parts, State state) {
ChannelName patternName = new ChannelName((byte[]) parts.get(1));
ChannelName name = new ChannelName((byte[]) parts.get(2));
return new PubSubPatternMessage(patternName, name, parts.get(3));
}
use of org.redisson.client.ChannelName in project redisson by redisson.
the class PubSubStatusDecoder method decode.
@Override
public PubSubStatusMessage decode(List<Object> parts, State state) {
PubSubType type = PubSubType.valueOf(parts.get(0).toString().toUpperCase());
ChannelName name = new ChannelName((byte[]) parts.get(1));
return new PubSubStatusMessage(type, name);
}
Aggregations