1078-查询终端属性完成

This commit is contained in:
648540858
2024-04-30 00:42:22 +08:00
parent 76580d8fdc
commit 5be7c7636e
2 changed files with 28 additions and 1 deletions

View File

@@ -5,6 +5,8 @@ import io.netty.channel.Channel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.SynchronousQueue;
@@ -109,6 +111,23 @@ public enum SessionManager {
return false;
}
public Boolean response(String key, Object data) {
SynchronousQueue<Object> queue = topicSubscribers.get(key);
if (queue != null) {
try {
return queue.offer(data, 2, TimeUnit.SECONDS);
} catch (InterruptedException e) {
log.error("{}", e.getMessage(), e);
}
}
log.warn("Not find response,key:{} data:{} ", key, data);
return false;
}
public List<String> getAllRequestKey() {
return new ArrayList<>(topicSubscribers.keySet());
}
private void unsubscribe(String key) {
topicSubscribers.remove(key);
}