初次提交
This commit is contained in:
parent
3dab4b367f
commit
08ee625021
|
@ -1,4 +1,4 @@
|
|||
package com.hivekion;
|
||||
package com.hivekion.startup;
|
||||
|
||||
import com.hivekion.thread.HandleReceiveThread;
|
||||
import com.hivekion.thread.HandleSendThread;
|
||||
|
@ -20,8 +20,8 @@ import org.springframework.stereotype.Component;
|
|||
public class Init {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
|
||||
public void appInit() {
|
||||
log.info("Init start");
|
||||
new Thread(new HandleSendThread()).start();
|
||||
new Thread(new HandleReceiveThread()).start();
|
||||
}
|
|
@ -60,13 +60,7 @@ public class WsServer {
|
|||
|
||||
|
||||
}
|
||||
try{
|
||||
session.getBasicRemote().sendText(testWeatherJson("start_rain"));
|
||||
Thread.sleep(10000);
|
||||
session.getBasicRemote().sendText(testWeatherJson("start_snow"));
|
||||
}catch (Exception e){
|
||||
log.error("error::",e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -120,27 +114,21 @@ public class WsServer {
|
|||
Object lock = lockMap.computeIfAbsent(scenarioId, k -> new Object());
|
||||
synchronized (lock) {
|
||||
Map<String, Map<String, Session>> roomMap = SESSION_MAP.get(String.valueOf(scenarioId));
|
||||
if (roomMap.containsKey(room)) {
|
||||
Map<String, Session> singleRoomMap = roomMap.get(room);
|
||||
singleRoomMap.forEach((sessionId, session) -> {
|
||||
try{
|
||||
session.getBasicRemote().sendText(message);
|
||||
}catch (Exception e){
|
||||
log.error("error::",e);
|
||||
}
|
||||
if(roomMap!=null){
|
||||
if (roomMap.containsKey(room)) {
|
||||
Map<String, Session> singleRoomMap = roomMap.get(room);
|
||||
singleRoomMap.forEach((sessionId, session) -> {
|
||||
try{
|
||||
session.getBasicRemote().sendText(message);
|
||||
}catch (Exception e){
|
||||
log.error("error::",e);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private String testWeatherJson(String tag){
|
||||
ResponseCmdInfo responseCmdInfo = new ResponseCmdInfo();
|
||||
responseCmdInfo.setCmdType(tag);
|
||||
responseCmdInfo.setRoom("123");
|
||||
responseCmdInfo.setScenarioId(2746);
|
||||
Map<String,Object> data = new HashMap<>();
|
||||
data.put("begTime","2028-03-09 10:00:00");
|
||||
data.put("endTime","2028-03-19 00:20:00");
|
||||
return JSON.toJSONString(responseCmdInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user