From efe39dda4d89c0bd4a35b2fa26beb5bfca03757b Mon Sep 17 00:00:00 2001 From: nite07 Date: Thu, 24 Oct 2024 16:23:50 +0800 Subject: [PATCH] u --- main.go | 3 ++- websocket/websocket.go | 17 +++++++++++++++++ websocket_handler.go | 18 ------------------ 3 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 websocket_handler.go diff --git a/main.go b/main.go index ab2f142..284feca 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "live-streamer/server" "live-streamer/streamer" "live-streamer/utils" + "live-streamer/websocket" "log" "os" @@ -16,7 +17,7 @@ import ( var GlobalStreamer *streamer.Streamer func main() { - server.NewServer(":8080", websocketRequestHandler) + server.NewServer(":8080", websocket.RequestHandler) server.GlobalServer.Run() if !utils.HasFFMPEG() { log.Fatal("ffmpeg not found") diff --git a/websocket/websocket.go b/websocket/websocket.go index 4866bd4..9c10469 100644 --- a/websocket/websocket.go +++ b/websocket/websocket.go @@ -1,5 +1,10 @@ package websocket +import ( + "live-streamer/streamer" + "os" +) + type RequestType string const ( @@ -18,3 +23,15 @@ type Date struct { VideoList []string `json:"videoList"` Output string `json:"output"` } + +func RequestHandler(reqType RequestType) { + switch reqType { + case TypeStreamNextVideo: + streamer.GlobalStreamer.Next() + case TypeStreamPrevVideo: + streamer.GlobalStreamer.Prev() + case TypeQuit: + streamer.GlobalStreamer.Close() + os.Exit(0) + } +} diff --git a/websocket_handler.go b/websocket_handler.go deleted file mode 100644 index dbdf8f1..0000000 --- a/websocket_handler.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "live-streamer/websocket" - "os" -) - -func websocketRequestHandler(reqType websocket.RequestType) { - switch reqType { - case websocket.TypeStreamNextVideo: - GlobalStreamer.Next() - case websocket.TypeStreamPrevVideo: - GlobalStreamer.Prev() - case websocket.TypeQuit: - GlobalStreamer.Close() - os.Exit(0) - } -}