WebSocket stabiler gemacht mit Puffern beim Broker
This commit is contained in:
1 parent
12523ddd0a
commit
c793e8b16d
10 files changed
+533
-37
No files matched your search
@@ -28,6 +28,40 @@
|
||||
const clean = String(path == null ? '' : path).replace(/^\/+/, '');
|
||||
return clean ? base + '/' + clean : (base || '/');
|
||||
};
|
||||
|
||||
// Stabile ID pro Browser-Tab. Sie übersteht ein Neuladen und ordnet
|
||||
// die WebSocket-Sitzung ihrer Nachrichten-Queue beim Broker zu.
|
||||
(function initClientSessionId() {
|
||||
const key = 'cmbnet:client-session:' + (window.CMBNET_TENANT || '');
|
||||
let sessionId = null;
|
||||
|
||||
try {
|
||||
sessionId = window.sessionStorage.getItem(key);
|
||||
} catch (error) {
|
||||
// sessionStorage kann in privaten Kontexten gesperrt sein.
|
||||
}
|
||||
|
||||
if (!sessionId) {
|
||||
if (window.crypto && typeof window.crypto.randomUUID === 'function') {
|
||||
sessionId = window.crypto.randomUUID();
|
||||
} else if (window.crypto && typeof window.crypto.getRandomValues === 'function') {
|
||||
const bytes = new Uint8Array(16);
|
||||
window.crypto.getRandomValues(bytes);
|
||||
sessionId = Array.from(bytes, value => value.toString(16).padStart(2, '0')).join('');
|
||||
} else {
|
||||
sessionId = 'sess-' + Date.now().toString(36) + '-' +
|
||||
Math.random().toString(36).slice(2, 12);
|
||||
}
|
||||
|
||||
try {
|
||||
window.sessionStorage.setItem(key, sessionId);
|
||||
} catch (error) {
|
||||
// Dann gilt die ID nur für den aktuellen Seitenaufruf.
|
||||
}
|
||||
}
|
||||
|
||||
window.CMBNET_CLIENT_SESSION_ID = sessionId;
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/pico.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/leaflet.css') }}">
|
||||
|
||||
Reference in new issue
Block a user