Files
mapo-core/MP.MON/Components/App.razor
T
Samuele Locatelli 35ce8e8066 MON:
- correzioni x gestione reconnect + stabile
- fix vari x condizioni errori visti in Jetco 8da aggiornare anche script PI)
2025-03-20 18:38:56 +01:00

108 lines
3.6 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@* <base href="/" /> *@
@* <base href="~/" /> *@
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="css/site.min.css" />
<link rel="stylesheet" href="lib/font-awesome/css/all.min.css" />
<link rel="stylesheet" href="MP.MON.styles.css" />
<link rel="icon" type="image/png" href="favicon.ico" />
<HeadOutlet />
</head>
<body>
<Routes />
<script src="lib/WindowSize.js"></script>
@* <script src="_framework/blazor.web.js"></script> *@
<script src="_framework/blazor.web.js" autostart="false"></script>
<script>
(() => {
const maximumRetryCount = 3;
const retryIntervalMilliseconds = 5000;
const reconnectModal = document.getElementById('reconnect-modal');
const startReconnectionProcess = () => {
reconnectModal.style.display = 'block';
let isCanceled = false;
(async () => {
for (let i = 0; i < maximumRetryCount; i++) {
reconnectModal.innerText = `Attempting to reconnect: ${i + 1} of ${maximumRetryCount}`;
await new Promise(resolve => setTimeout(resolve, retryIntervalMilliseconds));
if (isCanceled) {
return;
}
try {
const result = await Blazor.reconnect();
if (!result) {
// The server was reached, but the connection was rejected; reload the page.
location.reload();
return;
}
// Successfully reconnected to the server.
return;
} catch {
// Didn't reach the server; try again.
}
}
// Retried too many times; reload the page.
location.reload();
})();
return {
cancel: () => {
isCanceled = true;
reconnectModal.style.display = 'none';
},
};
};
let currentReconnectionProcess = null;
Blazor.start({
reconnectionHandler: {
onConnectionDown: () => currentReconnectionProcess ??= startReconnectionProcess(),
onConnectionUp: () => {
currentReconnectionProcess?.cancel();
currentReconnectionProcess = null;
}
}
});
})();
</script>
@* <script>
Blazor.start({
configureSignalR: function (builder) {
builder.withServerTimeout(30000).withKeepAliveInterval(15000);
}
});
</script> *@
@* <script>
Blazor.start({
reconnectionOptions: {
maxRetries: 3600,
retryIntervalMilliseconds: 2000
},
}).then(() => {
Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
console.log("Client reconnected, waiting 3 sec and reload!");
setTimeout(function () {
document.location.reload();
}, 3000);
}
});
</script> *@
</body>
</html>