copy from src/main/java/com/whyc/webSocket/DevLineSocket.java
copy to src/main/java/com/whyc/webSocket/DevLithiumAlmPopupSocket.java
File was copied from src/main/java/com/whyc/webSocket/DevLineSocket.java |
| | |
| | | import com.whyc.config.WebSocketConfig; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import com.whyc.service.DevInfService; |
| | | import com.whyc.service.DevLithiumAlarmDataService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | import java.io.IOException; |
| | | |
| | | /** |
| | | * 左侧列表 |
| | | * 锂电设备告警弹窗 |
| | | */ |
| | | @Component |
| | | @ServerEndpoint(value = "/lineSocket",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class) |
| | | public class DevLineSocket{ |
| | | @ServerEndpoint(value = "/devLithiumAlmPopup",encoders = WebSocketEncoder.class,configurator = WebSocketConfig.class) |
| | | public class DevLithiumAlmPopupSocket { |
| | | |
| | | private Session session; |
| | | |
| | | private Thread thread; |
| | | private static DevInfService dinfService; |
| | | private static DevLithiumAlarmDataService devLithiumAlarmDataService; |
| | | |
| | | private HttpSession httpSession; |
| | | |
| | | @Autowired |
| | | public void setDevInfService(DevInfService dinfService) { |
| | | DevLineSocket.dinfService = dinfService; |
| | | public void setDevLithiumAlarmDataService(DevLithiumAlarmDataService devLithiumAlarmDataService) { |
| | | DevLithiumAlmPopupSocket.devLithiumAlarmDataService = devLithiumAlarmDataService; |
| | | } |
| | | |
| | | @OnOpen |
| | |
| | | UserInf user = (UserInf) this.httpSession.getAttribute("user"); |
| | | final int userId = user.getUid(); |
| | | //final int userId = 101; |
| | | Thread thread = new Thread() { |
| | | Thread thread = new Thread("Thread_DevLithiumAlmPopupSocket") { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | while (!currentThread().isInterrupted()) { |
| | | Response res = dinfService.getDevType(userId); |
| | | Response res = devLithiumAlarmDataService.getPopup(userId); |
| | | session.getBasicRemote().sendObject(res); |
| | | sleep(4000); |
| | | } |