feat: 一些调整
This commit is contained in:
parent
5296aab048
commit
88bb491a55
|
|
@ -0,0 +1,29 @@
|
|||
package com.nflg.mobilebroken.admin.controller;
|
||||
|
||||
import com.nflg.mobilebroken.starter.service.impl.APPSSEManagerService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 统计分析相关
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/analysis")
|
||||
public class AnalysisController extends ControllerBase{
|
||||
|
||||
@Resource
|
||||
private APPSSEManagerService appSSEManagerService;
|
||||
|
||||
/**
|
||||
* 获取当前已连接SSE的客户端用户列表
|
||||
* @return 当前已连接SSE的客户端用户列表
|
||||
*/
|
||||
@GetMapping("getSSEConnects")
|
||||
public Collection<Integer> getSSEConnects(){
|
||||
return appSSEManagerService.getUserIds();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.nflg.mobilebroken.cfs.controller;
|
||||
|
||||
import com.nflg.mobilebroken.starter.service.impl.AdminSSEManagerService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 统计分析相关
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/analysis")
|
||||
public class AnalysisController extends ControllerBase{
|
||||
|
||||
@Resource
|
||||
private AdminSSEManagerService adminSSEManagerService;
|
||||
|
||||
/**
|
||||
* 获取当前已连接SSE的管理端用户列表
|
||||
* @return 当前已连接SSE的管理端用户列表
|
||||
*/
|
||||
@GetMapping("getSSEConnects")
|
||||
public Collection<Integer> getSSEConnects(){
|
||||
return adminSSEManagerService.getUserIds();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import com.nflg.mobilebroken.common.pojo.dto.SSEMessageDTO;
|
|||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface SSEManagerService {
|
||||
|
||||
|
|
@ -14,4 +15,6 @@ public interface SSEManagerService {
|
|||
void close(Integer userId);
|
||||
|
||||
void shutdown();
|
||||
|
||||
Collection<Integer> getUserIds();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
@ -47,4 +48,9 @@ public class APPSSEManagerService extends SSEManagerBase implements SSEManagerSe
|
|||
public void shutdown() {
|
||||
shutdown(EMITTERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Integer> getUserIds() {
|
||||
return EMITTERS.keySet();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
@ -47,4 +48,9 @@ public class AdminSSEManagerService extends SSEManagerBase implements SSEManager
|
|||
public void shutdown() {
|
||||
shutdown(EMITTERS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Integer> getUserIds() {
|
||||
return EMITTERS.keySet();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue