issue #10 HDMI입력시 화면 전환 기능 추가. Welcome에서 MQTT메시지 처리 로직 추가.
This commit is contained in:
@@ -29,7 +29,10 @@ var HotelTV = HotelTV || {
|
||||
'state': {
|
||||
'lang': 'kr',
|
||||
'menu': {
|
||||
'stage': null,
|
||||
'stage': {
|
||||
'cur':null,
|
||||
'prev':null,
|
||||
},
|
||||
'main': {
|
||||
'cnt': 0,
|
||||
'cur': null,
|
||||
@@ -45,9 +48,16 @@ var HotelTV = HotelTV || {
|
||||
'media': {
|
||||
'playing': false,
|
||||
},
|
||||
'tv':{
|
||||
'playing': false,
|
||||
},
|
||||
'hotkey': {
|
||||
"mm": {}
|
||||
},
|
||||
'schedule': {
|
||||
'flight_reflash': false,
|
||||
'weather_reflash': false
|
||||
},
|
||||
'token': null
|
||||
},
|
||||
'carts': {
|
||||
@@ -163,6 +173,7 @@ function __fxn_Set_DebugOpt() {
|
||||
|
||||
HotelTV.Init = async function() {
|
||||
console.log("Start Initialization:: ");
|
||||
|
||||
//STEP#01::> Shutdown Channel
|
||||
HotelTV.hcap.ChannelShutDown();
|
||||
|
||||
@@ -460,8 +471,6 @@ HotelTV.LoadWelCome = async function() {
|
||||
console.error("Display Error page for get translation info");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Set checkined guest language
|
||||
HotelTV.state.lang = HotelTV.guestinfo.language;
|
||||
|
||||
@@ -470,11 +479,92 @@ HotelTV.LoadWelCome = async function() {
|
||||
|
||||
//await HotelTV.hcap.ShowDevInfo();
|
||||
HotelTV.ui_welcome.Show();
|
||||
|
||||
|
||||
//STEP#06 Register Service web worker
|
||||
if (window.SharedWorker) {
|
||||
const myWorker = new SharedWorker("./lib/hoteltv.service.js");
|
||||
|
||||
myWorker.port.postMessage({
|
||||
'cmd': "start_service",
|
||||
"param": {
|
||||
"token": HotelTV.state.token,
|
||||
"dev_family": HotelTV.devinfo.model_name.substring(2, HotelTV.devinfo.model_name.length - 1),
|
||||
"dev_snum": HotelTV.devinfo.serial_number,
|
||||
"svrinfo": HotelTV.svrinfo,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
myWorker.port.onmessage = function(e) {
|
||||
let recvMsg = e.data;
|
||||
//console.log(`Recv Msg[${recvMsg.event}]::> ${recvMsg.ret} ::> ${recvMsg.data}`);
|
||||
//console.log(`Recv Msg[${recvMsg.event}]::> ${recvMsg.ret}`);
|
||||
if (recvMsg.event == "update_report") {
|
||||
HotelTV.hcap.GetUptime();
|
||||
HotelTV.hcap.GetDeviceUsage().then(_usage => {
|
||||
//console.log(`USAGE::> CPU[${_usage.cpu}%]`);
|
||||
HotelTV.api.ReportBrief(HotelTV.devinfo, HotelTV.guestinfo, _usage);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.error('Your browser doesn\'t support web workers.')
|
||||
}
|
||||
|
||||
//STEP#07 MQTT Service
|
||||
if (HotelTV.services) {
|
||||
if (HotelTV.services.mqtt) {
|
||||
let _mqttSvcInfo = HotelTV.services.mqtt;
|
||||
|
||||
if (_mqttSvcInfo.protocol == "ws") {
|
||||
HotelTV.services.client = mqtt.connect(
|
||||
//'ws://' + HotelTV.svrinfo.ipaddr + ':9001',
|
||||
'ws://' + _mqttSvcInfo.host + ':' + _mqttSvcInfo.port, {
|
||||
clean: true, // retain session
|
||||
connectTimeout: 4000, // Timeout period
|
||||
username: _mqttSvcInfo.username,
|
||||
password: _mqttSvcInfo.password,
|
||||
clientId: 'mqtt_sid_' + HotelTV.devinfo.serial_number.substring(0, 12)
|
||||
}
|
||||
);
|
||||
|
||||
HotelTV.services.client.on('connect', function() {
|
||||
HotelTV.services.client.subscribe(_mqttSvcInfo.topic, function(err) {
|
||||
if (err) {
|
||||
console.error(`Fail to subscribe::TOPIC[${_mqttSvcInfo.topic}]`);
|
||||
} else {
|
||||
console.log(`Success to subscribe::TOPIC[${_mqttSvcInfo.topic}]`);
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
HotelTV.services.client.on('message', function(topic, message) {
|
||||
let szMsg = message.toString();
|
||||
HotelTV.ui_welcome.MqttEvent(szMsg);
|
||||
//MQTT메시지 종료 하려면 아래 end호출
|
||||
//HotelTV.services.client.end()
|
||||
})
|
||||
|
||||
HotelTV.services.client.on('error', function(error) {
|
||||
// message is Buffer
|
||||
console.error(error.toString());
|
||||
//HotelTV.services.client.end()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HotelTV.UnloadWelCome = async function() {
|
||||
sessionStorage.setItem("state", JSON.stringify(HotelTV.state));
|
||||
HotelTV.ui_welcome.Close();
|
||||
|
||||
//MQTT Disconnect
|
||||
if( HotelTV.services.client ){
|
||||
HotelTV.services.client.end();
|
||||
}
|
||||
|
||||
if (HotelTV.state['registration'].license == 'hotel-full') {
|
||||
setTimeout(function() {
|
||||
window.location.replace('./app_hoteltv_full.html');
|
||||
@@ -484,6 +574,9 @@ HotelTV.UnloadWelCome = async function() {
|
||||
|
||||
|
||||
HotelTV.LoadAppFull = async function() {
|
||||
//Turn Off HCAP api log
|
||||
extDisableHcapConsoleLog = true;
|
||||
|
||||
HotelTV.ui_utils.SetBusy(true);
|
||||
|
||||
//STEP#01: Load session info
|
||||
@@ -516,8 +609,8 @@ HotelTV.LoadAppFull = async function() {
|
||||
console.error("Display Error page for get amenity carts info");
|
||||
}
|
||||
|
||||
HotelTV.carts.roomservice = await HotelTV.api.GetRoomserviceCarts();
|
||||
try {
|
||||
HotelTV.carts.roomservice = await HotelTV.api.GetRoomserviceCarts();
|
||||
} catch (_error) {
|
||||
console.error("Display Error page for get roomservicec carts info");
|
||||
}
|
||||
@@ -618,7 +711,9 @@ HotelTV.LoadAppFull = async function() {
|
||||
HotelTV.flight =recvMsg.data;
|
||||
}
|
||||
} else if (recvMsg.event == "update_weather") {
|
||||
//
|
||||
if (recvMsg.ret === "OK") {
|
||||
HotelTV.weather =recvMsg.data;
|
||||
}
|
||||
} else if (recvMsg.event == "update_report") {
|
||||
HotelTV.hcap.GetUptime();
|
||||
HotelTV.hcap.GetDeviceUsage().then(_usage => {
|
||||
@@ -626,6 +721,9 @@ HotelTV.LoadAppFull = async function() {
|
||||
HotelTV.api.ReportBrief(HotelTV.devinfo, HotelTV.guestinfo, _usage);
|
||||
});
|
||||
}
|
||||
|
||||
// BGServiceEvent function for post processing
|
||||
HotelTV.ui_appfull.BGServiceEvent(recvMsg.event);
|
||||
}
|
||||
} else {
|
||||
console.error('Your browser doesn\'t support web workers.')
|
||||
@@ -637,7 +735,7 @@ HotelTV.LoadAppFull = async function() {
|
||||
let _mqttSvcInfo = HotelTV.services.mqtt;
|
||||
|
||||
if (_mqttSvcInfo.protocol == "ws") {
|
||||
var client = mqtt.connect(
|
||||
HotelTV.services.client = mqtt.connect(
|
||||
//'ws://' + HotelTV.svrinfo.ipaddr + ':9001',
|
||||
'ws://' + _mqttSvcInfo.host + ':' + _mqttSvcInfo.port, {
|
||||
clean: true, // retain session
|
||||
@@ -648,8 +746,8 @@ HotelTV.LoadAppFull = async function() {
|
||||
}
|
||||
);
|
||||
|
||||
client.on('connect', function() {
|
||||
client.subscribe(_mqttSvcInfo.topic, function(err) {
|
||||
HotelTV.services.client.on('connect', function() {
|
||||
HotelTV.services.client.subscribe(_mqttSvcInfo.topic, function(err) {
|
||||
if (err) {
|
||||
console.error(`Fail to subscribe::TOPIC[${_mqttSvcInfo.topic}]`);
|
||||
} else {
|
||||
@@ -658,17 +756,17 @@ HotelTV.LoadAppFull = async function() {
|
||||
});
|
||||
})
|
||||
|
||||
client.on('message', function(topic, message) {
|
||||
HotelTV.services.client.on('message', function(topic, message) {
|
||||
let szMsg = message.toString();
|
||||
HotelTV.ui_appfull.MqttEvent(szMsg);
|
||||
//MQTT메시지 종료 하려면 아래 end호출
|
||||
//client.end()
|
||||
//HotelTV.services.client.end()
|
||||
})
|
||||
|
||||
client.on('error', function(error) {
|
||||
HotelTV.services.client.on('error', function(error) {
|
||||
// message is Buffer
|
||||
console.error(error.toString());
|
||||
//client.end()
|
||||
//HotelTV.services.client.end()
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -676,11 +774,14 @@ HotelTV.LoadAppFull = async function() {
|
||||
|
||||
|
||||
//
|
||||
HotelTV.hcap.Test();
|
||||
//HotelTV.hcap.Test();
|
||||
}
|
||||
|
||||
HotelTV.UnloadAppFull = async function() {
|
||||
|
||||
//MQTT Disconnect
|
||||
if( HotelTV.services.client ){
|
||||
HotelTV.services.client.end();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user