You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
package com.bx.imserver.task;
|
|
|
|
import com.bx.imcommon.contant.RedisKey;
|
|
import com.bx.imcommon.enums.IMCmdType;
|
|
import com.bx.imcommon.model.GroupMessageInfo;
|
|
import com.bx.imcommon.model.IMRecvInfo;
|
|
import com.bx.imserver.netty.IMServerMap;
|
|
import com.bx.imserver.netty.processor.MessageProcessor;
|
|
import com.bx.imserver.netty.processor.ProcessorFactory;
|
|
import com.bx.imserver.netty.ws.WebSocketServer;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.List;
|
|
|
|
@Slf4j
|
|
@Component
|
|
public class PullUnreadGroupMessageTask extends AbstractPullMessageTask {
|
|
|
|
@Autowired
|
|
private WebSocketServer WSServer;
|
|
|
|
@Autowired
|
|
private RedisTemplate<String,Object> redisTemplate;
|
|
|
|
|
|
|
|
@Override
|
|
public void pullMessage() {
|
|
// 从redis拉取未读消息
|
|
String key = RedisKey.IM_UNREAD_GROUP_QUEUE + IMServerMap.serverId;
|
|
List messageInfos = redisTemplate.opsForList().range(key,0,-1);
|
|
for(Object o: messageInfos){
|
|
redisTemplate.opsForList().leftPop(key);
|
|
IMRecvInfo<GroupMessageInfo> recvInfo = (IMRecvInfo)o;
|
|
MessageProcessor processor = ProcessorFactory.createProcessor(IMCmdType.GROUP_MESSAGE);
|
|
processor.process(recvInfo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|