| | |
| | | package com.whyc.webSocket; |
| | | |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.pojo.RtState; |
| | | import com.whyc.pojo.StationInf; |
| | | import com.whyc.service.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.websocket.*; |
| | | import javax.websocket.server.ServerEndpoint; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.CountDownLatch; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * packageName com.whyc.websocket |
| | |
| | | * @version JDK 8 |
| | | * @className BattSocket (此处以class为例) |
| | | * @date 2024/6/15 |
| | | * @description TODO |
| | | * @description |
| | | */ |
| | | @Component |
| | | @ServerEndpoint(value = "/batt", encoders = WebSocketEncoder.class) |
| | |
| | | @OnMessage |
| | | public void onMessage(Session session, String message) { |
| | | int binfId=Integer.valueOf(message); |
| | | thread = new Thread("Thread_RealTime") { |
| | | thread = new Thread("Thread_BattSocket") { |
| | | @Override |
| | | public void run() { |
| | | Map<String, Object> res = new HashMap<>(); |
| | | while (runFlag && !isInterrupted()) { |
| | | Thread thread = currentThread(); |
| | | threadFlagMap.put(thread.getId(), true); |
| | | Map<String, Object> res = new HashMap<>(); |
| | | try { |
| | | ThreadPoolExecutor poolExecutor = ThreadPoolExecutorFactory.getPoolExecutor(); |
| | | CountDownLatch latch = new CountDownLatch(4); |