初次提交
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.HandleReceiveThread;
|
||||||
import com.hivekion.thread.HandleSendThread;
|
import com.hivekion.thread.HandleSendThread;
|
||||||
|
|
@ -20,8 +20,8 @@ import org.springframework.stereotype.Component;
|
||||||
public class Init {
|
public class Init {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void appInit() {
|
||||||
|
log.info("Init start");
|
||||||
new Thread(new HandleSendThread()).start();
|
new Thread(new HandleSendThread()).start();
|
||||||
new Thread(new HandleReceiveThread()).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,6 +114,7 @@ public class WsServer {
|
||||||
Object lock = lockMap.computeIfAbsent(scenarioId, k -> new Object());
|
Object lock = lockMap.computeIfAbsent(scenarioId, k -> new Object());
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
Map<String, Map<String, Session>> roomMap = SESSION_MAP.get(String.valueOf(scenarioId));
|
Map<String, Map<String, Session>> roomMap = SESSION_MAP.get(String.valueOf(scenarioId));
|
||||||
|
if(roomMap!=null){
|
||||||
if (roomMap.containsKey(room)) {
|
if (roomMap.containsKey(room)) {
|
||||||
Map<String, Session> singleRoomMap = roomMap.get(room);
|
Map<String, Session> singleRoomMap = roomMap.get(room);
|
||||||
singleRoomMap.forEach((sessionId, session) -> {
|
singleRoomMap.forEach((sessionId, session) -> {
|
||||||
|
|
@ -132,15 +127,8 @@ public class WsServer {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
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