DESKTOP-PC6TBNS\강환석씨

event divergence to client

......@@ -34,6 +34,7 @@ module.exports = (server, app) => {
let Discomport_index={};
let Ultra_Violet_index={};
let sending_to_client_info={};
let client_send={};
socket.on("connection", () => {
API_CALL = setInterval(() => {
......@@ -48,16 +49,16 @@ module.exports = (server, app) => {
heat : Sensible_T.weather.wIndex.heatIndex[0].current.index, //열지수
sensible_temperature : Sensible_T.weather.wIndex.wctIndex[0].current.index, //체감온도
discomport : Discomport_index.weather.wIndex.thIndex[0].current.index, //불쾌지수
UV : Ultra_Violet_index.weather.wIndex.uvindex[0].day00.index,
windspd : Current_Weather.weather.minutely[0].wind.wspd,
sky : Current_Weather.weather.minutely[0].sky.code,
rain : Current_Weather.weather.minutely[0].rain.last24hour,
current_temperature : Current_Weather.weather.minutely[0].temperature.tc,
lightning : Current_Weather.weather.minutely[0].lightning,
warning : common.alertYn,
typhoon : Current_Weather.common.stormYn,
time : Current_Weather.weather.minutely[0].timeObservation,
death_prob:0
UV : Ultra_Violet_index.weather.wIndex.uvindex[0].day00.index, //자외선지수
windspd : Current_Weather.weather.minutely[0].wind.wspd, //바람 속도
sky : Current_Weather.weather.minutely[0].sky.code, //하늘 상태
rain : Current_Weather.weather.minutely[0].rain.last24hour, //강수량
current_temperature : Current_Weather.weather.minutely[0].temperature.tc, //현재 온도
lightning : Current_Weather.weather.minutely[0].lightning, //현재 낙뢰
warning : Current_Weather.common.alertYn, //현재 특보 유무
typhoon : Current_Weather.common.stormYn, //현재 태풍
time : Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각
death_prob:0 //확률
}
info.death_prob += info.sky.substr(5)*1 //하늘 상태에 따라 확률 증가
......@@ -75,8 +76,14 @@ module.exports = (server, app) => {
+ (info.windspd*3) + (info.rain/10) + (abs(info.current_temperature-15)/2)
);
client_send={
rain : info.rain,
wind : info.windspd,
temperature : info.current_temperature,
death : info.death_prob
}
socket.emit("weatherInfo_minutely_send_to_client",info); // 클라이언트에게 이벤트 발산
socket.emit("weatherInfo_minutely_send_to_client",client_send); // 클라이언트에게 정보 담아서 이벤트 발산
}, 60 * 1000); //1분마다 호출
});
......