update 优化 sse发送消息 增加token有效期判断
This commit is contained in:
parent
7297053dd6
commit
239d59c864
@ -1,5 +1,6 @@
|
|||||||
package org.dromara.common.sse.core;
|
package org.dromara.common.sse.core;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.dromara.common.redis.utils.RedisUtils;
|
import org.dromara.common.redis.utils.RedisUtils;
|
||||||
@ -71,6 +72,11 @@ public class SseEmitterManager {
|
|||||||
if (emitters != null) {
|
if (emitters != null) {
|
||||||
for (Map.Entry<String, SseEmitter> entry : emitters.entrySet()) {
|
for (Map.Entry<String, SseEmitter> entry : emitters.entrySet()) {
|
||||||
try {
|
try {
|
||||||
|
// token 无效或已过期
|
||||||
|
if (StpUtil.stpLogic.getTokenActiveTimeoutByToken(entry.getKey()) < -1) {
|
||||||
|
emitters.remove(entry.getKey());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
entry.getValue().send(SseEmitter.event()
|
entry.getValue().send(SseEmitter.event()
|
||||||
.name("message")
|
.name("message")
|
||||||
.data(message));
|
.data(message));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user