From af9c1e93418696bae3118687c1dcc1606476ad88 Mon Sep 17 00:00:00 2001 From: Matiss Jurevics Date: Thu, 22 Jan 2026 14:00:00 +0000 Subject: [PATCH] feat(simulator): support phase5 publish and subscribe media credentials --- Backend/public/mobile-sim.html | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Backend/public/mobile-sim.html b/Backend/public/mobile-sim.html index 76676c8..46f93ae 100644 --- a/Backend/public/mobile-sim.html +++ b/Backend/public/mobile-sim.html @@ -158,6 +158,7 @@ +

         
 
@@ -165,6 +166,7 @@
           

Camera Actions

+

         
       
@@ -271,6 +273,12 @@
           state.lastStreamSessionId = payload.streamSessionId;
           render();
           log('stream:started', payload);
+
+          if (state.device?.role === 'client') {
+            deviceFetch(`/streams/${payload.streamSessionId}/subscribe-credentials`)
+              .then((credentials) => log('auto subscribe credentials', credentials))
+              .catch((error) => log('auto subscribe credentials failed', { error: error.message }));
+          }
         });
         state.socket.on('stream:ended', (payload) => log('stream:ended', payload));
         state.socket.on('motion:detected', (payload) => log('motion:detected', payload));
@@ -286,6 +294,11 @@
                 method: 'POST',
                 body: JSON.stringify({}),
               });
+
+              const publishCredentials = await deviceFetch(
+                `/streams/${payload.payload.streamSessionId}/publish-credentials`,
+              );
+              log('auto publish credentials', publishCredentials);
             }
 
             if (payload.commandType === 'stop_stream' && payload.payload?.streamSessionId) {
@@ -412,6 +425,16 @@
         }
       });
 
+      $('fetchSubscribeBtn').addEventListener('click', async () => {
+        try {
+          if (!state.lastStreamSessionId) throw new Error('No known stream session');
+          const payload = await deviceFetch(`/streams/${state.lastStreamSessionId}/subscribe-credentials`);
+          log('subscribe credentials', payload);
+        } catch (error) {
+          log('subscribe credentials failed', { error: error.message });
+        }
+      });
+
       $('startMotionBtn').addEventListener('click', async () => {
         try {
           const payload = await deviceFetch('/events/motion/start', {
@@ -442,6 +465,16 @@
         }
       });
 
+      $('fetchPublishBtn').addEventListener('click', async () => {
+        try {
+          if (!state.lastStreamSessionId) throw new Error('No known stream session');
+          const payload = await deviceFetch(`/streams/${state.lastStreamSessionId}/publish-credentials`);
+          log('publish credentials', payload);
+        } catch (error) {
+          log('publish credentials failed', { error: error.message });
+        }
+      });
+
       render();