DESKTOP-PC6TBNS\강환석씨

db insertion complete

......@@ -35,6 +35,7 @@ module.exports = (server, app) => {
let Ultra_Violet_index={};
let sending_to_client_info={};
let client_send={};
let sql;
socket.on("connection", () => {
API_CALL = setInterval(() => {
......@@ -77,13 +78,19 @@ module.exports = (server, app) => {
);
client_send={
rain : info.rain,
time : info.time,
wind : info.windspd,
temperature : info.current_temperature,
rain : info.rain,
death : info.death_prob
}
};
socket.emit("weatherInfo_minutely_send_to_client",client_send); // 클라이언트에게 정보 담아서 이벤트 발산
//db에 저장
sql="INSERT INTO weatherInfo (time,wind,temperature,rain,prob) VALUES (?,?,?,?,?)";
db.query(sql,[client_send.time,client_send.wind,client_send.temperature,client_send.rain,client_send.death],(err,result)=>{
if(err) console.log(err);
socket.emit("weatherInfo_minutely_send_to_client",client_send); // 클라이언트에게 정보 담아서 이벤트 발산
})
}, 60 * 1000); //1분마다 호출
});
......