From c29113f80732a2c032bf5911898ac3e4829c7231 Mon Sep 17 00:00:00 2001
From: Falk Rehse <falk.rehse@tu-dortmund.de>
Date: Wed, 30 Nov 2022 15:04:47 +0100
Subject: [PATCH] Rename to websockets

---
 Dockerfile                          |  8 ++++----
 src/http.rs                         |  2 +-
 src/main.rs                         | 14 +++++++-------
 src/{websocket.rs => websockets.rs} |  6 +++---
 4 files changed, 15 insertions(+), 15 deletions(-)
 rename src/{websocket.rs => websockets.rs} (93%)

diff --git a/Dockerfile b/Dockerfile
index 2bde94e..fc6d1e4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -19,11 +19,11 @@ RUN yarn build
 
 FROM docker.io/library/alpine:latest
 
-ARG SPOCCIFY_HTTP_BIND_HOST 0.0.0.0
-ARG SPOCCIFY_HTTP_BIND_PORT 9000
+ENV SPOCCIFY_HTTP_BIND_HOST 0.0.0.0
+ENV SPOCCIFY_HTTP_BIND_PORT 9000
 
-ARG SPOCCIFY_WEBSOCKET_BIND_HOST 0.0.0.0
-ARG SPOCCIFY_WEBSOCKET_BIND_PORT 9001
+ENV SPOCCIFY_WEBSOCKETS_BIND_HOST 0.0.0.0
+ENV SPOCCIFY_WEBSOCKETS_BIND_PORT 9001
 
 RUN apk add ffmpeg yt-dlp
 COPY --from=builder-backend /usr/src/spoccify/target/release/spoccify /spoccify/spoccify
diff --git a/src/http.rs b/src/http.rs
index 5d2a982..244cb0c 100644
--- a/src/http.rs
+++ b/src/http.rs
@@ -10,7 +10,7 @@ use tower_http::services::ServeDir;
 
 // use crate::song::Song;
 
-pub async fn handle_http(http_bind_address: &str, /* playlist_websocket: &Mutable<Vec<Song>> */) {
+pub async fn handle_http(http_bind_address: &str, /* playlist: &Mutable<Vec<Song>> */) {
     println!("Listening for http connections on {}!", http_bind_address);
 
     async fn handle_404() -> (StatusCode, &'static str) {
diff --git a/src/main.rs b/src/main.rs
index 15c15a4..5ae06ec 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,7 +4,7 @@ mod http;
 mod player;
 mod song;
 mod util;
-mod websocket;
+mod websockets;
 mod websocket_command;
 
 use futures_signals::signal::Mutable;
@@ -34,17 +34,17 @@ async fn main() {
     let client_token =
         Arc::new(env::var("SPOCCIFY_CLIENT_TOKEN").expect("No client token provided!"));
 
-    let websocket_bind_host =
-        env::var("SPOCCIFY_WEBSOCKET_BIND_HOST").unwrap_or("127.0.0.1".to_owned());
-    let websocket_bind_port = env::var("SPOCCIFY_WEBSOCKET_BIND_PORT").unwrap_or("9001".to_owned());
+    let websockets_bind_host =
+        env::var("SPOCCIFY_WEBSOCKETS_BIND_HOST").unwrap_or("127.0.0.1".to_owned());
+    let websockets_bind_port = env::var("SPOCCIFY_WEBSOCKETS_BIND_PORT").unwrap_or("9001".to_owned());
 
-    let websocket_bind_address = format!("{}:{}", websocket_bind_host, websocket_bind_port);
+    let websockets_bind_address = format!("{}:{}", websockets_bind_host, websockets_bind_port);
 
     let _websockets_task = tokio::task::spawn(async move {
-        websocket::handle_websockets(
+        websockets::handle_websockets(
             &player_token,
             &client_token,
-            &websocket_bind_address,
+            &websockets_bind_address,
             &playlist_websockets,
         )
         .await;
diff --git a/src/websocket.rs b/src/websockets.rs
similarity index 93%
rename from src/websocket.rs
rename to src/websockets.rs
index 48bbc72..bb5b055 100644
--- a/src/websocket.rs
+++ b/src/websockets.rs
@@ -13,14 +13,14 @@ use crate::song::Song;
 pub async fn handle_websockets(
     player_token: &Arc<String>,
     client_token: &Arc<String>,
-    websocket_bind_address: &str,
+    websockets_bind_address: &str,
     playlist_websocket: &Mutable<Vec<Song>>,
 ) {
-    let server = TcpListener::bind(websocket_bind_address).expect("Failed to bind websocket port!");
+    let server = TcpListener::bind(websockets_bind_address).expect("Failed to bind websocket port!");
 
     println!(
         "Listening for websocket connections on {}!",
-        websocket_bind_address
+        websockets_bind_address
     );
 
     for stream in server.incoming() {
-- 
GitLab