barcode-host/Server/wwwroot/js/notification.js

19 lines
721 B
JavaScript

"use strict";
var connection = new signalR.HubConnectionBuilder().withUrl("/NotificationHub").build();
connection.on("NotifyAll", function (data) {
if (data.keyPressEvent && data.lastScanServiceResultValue) {
var innerText = `${data.keyPressEvent.dateTime} - [${data.lastScanServiceResultValue}]`;
document.getElementById("lastScanServiceResultValue").innerText = innerText;
}
else if (data.httpContentBody) {
var innerText = `${data.httpContentBody}]`; //JSON.parse() // JSON.stringify()
document.getElementById("httpContentBody").innerText = innerText;
}
});
connection.start().then(function () {
}).catch(function (err) {
return console.error(err.toString());
});