aboutsummaryrefslogtreecommitdiff
path: root/templates/client.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/client.html')
-rw-r--r--templates/client.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/templates/client.html b/templates/client.html
new file mode 100644
index 0000000..e03394a
--- /dev/null
+++ b/templates/client.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Client {{ client_id }} - Camera Streams</title>
+ <style>
+ .camera-stream { display: inline-block; margin: 10px; }
+ video { border: 1px solid #333; }
+ </style>
+</head>
+<body>
+ <h1>Camera Streams for client: {{ client_id }}</h1>
+ <div class="streams-container">
+ {% for camera_id in camera_ids %}
+ <div class="camera-stream">
+ <h2>Camera {{ camera_id }}</h2>
+ <img id="video-{{ camera_id }}" width="640" height="480" />
+ </div>
+ {% endfor %}
+ </div>
+ <script>
+ // For each camera, open a WebSocket and update the corresponding <img>
+ {% for camera_id in camera_ids %}
+ (function() {
+ let ws = new WebSocket('ws://' + window.location.host + '/ws/{{ client_id }}/{{ camera_id }}');
+ let image = document.getElementById('video-{{ camera_id }}');
+ let currentUrl = null;
+ ws.onmessage = function(event) {
+ if (currentUrl) {
+ URL.revokeObjectURL(currentUrl);
+ }
+ currentUrl = URL.createObjectURL(event.data);
+ image.src = currentUrl;
+ };
+ ws.onclose = function(event) {
+ console.log('WebSocket closed for camera {{ camera_id }}:', event);
+ };
+ ws.onerror = function(event) {
+ console.log('WebSocket error for camera {{ camera_id }}:', event);
+ };
+ window.addEventListener('beforeunload', function() {
+ ws.close();
+ });
+ })();
+ {% endfor %}
+ </script>
+</body>
+</html>