From f2b2e5c61c055f870da44ea8b98d2705b871415c Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 20 Jun 2021 17:26:23 -0700 Subject: [PATCH] Revert "Remove ping requests now that it has been consolidated with status requests" This reverts commit d9a6be2ac62a58415471b036f6b18ac35db2dbd8. --- webroot/js/app-video-only.js | 7 +++++++ webroot/js/app.js | 7 +++++++ webroot/js/utils/constants.js | 1 + 3 files changed, 15 insertions(+) diff --git a/webroot/js/app-video-only.js b/webroot/js/app-video-only.js index b19b2c6fa..bbfd0f4a3 100644 --- a/webroot/js/app-video-only.js +++ b/webroot/js/app-video-only.js @@ -20,6 +20,7 @@ import { import { URL_CONFIG, URL_STATUS, + URL_VIEWER_PING, TIMER_STATUS_UPDATE, TIMER_STREAM_DURATION_COUNTER, TEMP_IMAGE, @@ -119,6 +120,12 @@ export default class VideoOnly extends Component { this.handleOfflineMode(); this.handleNetworkingError(`Stream status: ${error}`); }); + + // Ping the API to let them know we're an active viewer + fetch(URL_VIEWER_PING).catch((error) => { + this.handleOfflineMode(); + this.handleNetworkingError(`Viewer PING error: ${error}`); + }); } setConfigData(data = {}) { diff --git a/webroot/js/app.js b/webroot/js/app.js index 7ada8bcbf..43ef0a906 100644 --- a/webroot/js/app.js +++ b/webroot/js/app.js @@ -41,6 +41,7 @@ import { URL_CONFIG, URL_OWNCAST, URL_STATUS, + URL_VIEWER_PING, WIDTH_SINGLE_COL, } from './utils/constants.js'; @@ -187,6 +188,12 @@ export default class App extends Component { this.handleOfflineMode(); this.handleNetworkingError(`Stream status: ${error}`); }); + + // Ping the API to let them know we're an active viewer + fetch(URL_VIEWER_PING).catch((error) => { + this.handleOfflineMode(); + this.handleNetworkingError(`Viewer PING error: ${error}`); + }); } setConfigData(data = {}) { diff --git a/webroot/js/utils/constants.js b/webroot/js/utils/constants.js index af05c5cb0..89441aa2b 100644 --- a/webroot/js/utils/constants.js +++ b/webroot/js/utils/constants.js @@ -4,6 +4,7 @@ export const URL_STATUS = `/api/status`; export const URL_CHAT_HISTORY = `/api/chat`; export const URL_CUSTOM_EMOJIS = `/api/emoji`; export const URL_CONFIG = `/api/config`; +export const URL_VIEWER_PING = `/api/ping`; // TODO: This directory is customizable in the config. So we should expose this via the config API. export const URL_STREAM = `/hls/stream.m3u8`;