|
|
@@ -6,12 +6,12 @@ import com.bx.imcommon.contant.IMRedisKey;
|
|
|
import com.bx.imcommon.enums.IMCmdType;
|
|
|
import com.bx.imcommon.model.IMHeartbeatInfo;
|
|
|
import com.bx.imcommon.model.IMSendInfo;
|
|
|
+import com.bx.imcommon.mq.RedisMQTemplate;
|
|
|
import com.bx.imserver.constant.ChannelAttrKey;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.util.AttributeKey;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
@@ -22,12 +22,12 @@ import java.util.concurrent.TimeUnit;
|
|
|
@RequiredArgsConstructor
|
|
|
public class HeartbeatProcessor extends AbstractMessageProcessor<IMHeartbeatInfo> {
|
|
|
|
|
|
- private final RedisTemplate<String, Object> redisTemplate;
|
|
|
+ private final RedisMQTemplate redisMQTemplate;
|
|
|
|
|
|
@Override
|
|
|
public void process(ChannelHandlerContext ctx, IMHeartbeatInfo beatInfo) {
|
|
|
// 响应ws
|
|
|
- IMSendInfo sendInfo = new IMSendInfo();
|
|
|
+ IMSendInfo<Object> sendInfo = new IMSendInfo<>();
|
|
|
sendInfo.setCmd(IMCmdType.HEART_BEAT.code());
|
|
|
ctx.channel().writeAndFlush(sendInfo);
|
|
|
// 设置属性
|
|
|
@@ -41,7 +41,7 @@ public class HeartbeatProcessor extends AbstractMessageProcessor<IMHeartbeatInfo
|
|
|
AttributeKey<Integer> terminalAttr = AttributeKey.valueOf(ChannelAttrKey.TERMINAL_TYPE);
|
|
|
Integer terminal = ctx.channel().attr(terminalAttr).get();
|
|
|
String key = String.join(":", IMRedisKey.IM_USER_SERVER_ID, userId.toString(), terminal.toString());
|
|
|
- redisTemplate.expire(key, IMConstant.ONLINE_TIMEOUT_SECOND, TimeUnit.SECONDS);
|
|
|
+ redisMQTemplate.expire(key, IMConstant.ONLINE_TIMEOUT_SECOND, TimeUnit.SECONDS);
|
|
|
}
|
|
|
AttributeKey<Long> userIdAttr = AttributeKey.valueOf(ChannelAttrKey.USER_ID);
|
|
|
Long userId = ctx.channel().attr(userIdAttr).get();
|