feat: 收到频道消息后先移除前缀再触发时间

This commit is contained in:
2023-11-20 17:03:00 +08:00
parent 04cea1896e
commit da710e5af8
5 changed files with 9 additions and 6 deletions

View File

@@ -448,7 +448,7 @@ public abstract class BallAPI {
*/
public void sendBallMessage(@NotNull String channel, @NotNull BallMessage message, boolean prefix, boolean block) {
if (prefix) {
channel = ballConfig.getChannelPrefix() + ":" + channel;
channel = ballConfig.getChannelPrefix() + channel;
}
if (block) {
pubConnection.sync().publish(channel, message);
@@ -466,7 +466,7 @@ public abstract class BallAPI {
public void subscribe(@NotNull String... channel) {
for (int i = 0; i < channel.length; i++) {
channel[i] = ballConfig.getChannelPrefix() + ":" + channel[i];
channel[i] = ballConfig.getChannelPrefix() + channel[i];
}
subConnection.sync().subscribe(channel);
}
@@ -477,7 +477,7 @@ public abstract class BallAPI {
public void unsubscribe(@NotNull String... channel) {
for (int i = 0; i < channel.length; i++) {
channel[i] = ballConfig.getChannelPrefix() + ":" + channel[i];
channel[i] = ballConfig.getChannelPrefix() + channel[i];
}
subConnection.sync().unsubscribe(channel);
}

View File

@@ -19,6 +19,9 @@ public class BallRedisListener implements RedisPubSubListener<String, BallMessag
@Override
public void message(String channel, BallMessage ballMessage) {
if (channel.startsWith(BallAPI.getInstance().getBallConfig().getChannelPrefix())) {
channel = channel.substring(BallAPI.getInstance().getBallConfig().getChannelPrefix().length());
}
BallAPI api = BallAPI.getInstance();
if (ballMessage.getReceiverType() != null && ballMessage.getReceiverType() != api.getLocalServerInfo().getType()) {
return;