live-streamer/websocket/websocket.go

38 lines
763 B
Go
Raw Normal View History

2024-10-23 14:35:37 -04:00
package websocket
2024-10-24 04:23:50 -04:00
import (
"live-streamer/streamer"
"os"
)
2024-10-23 17:06:19 -04:00
type RequestType string
2024-10-23 14:35:37 -04:00
2024-10-23 17:06:19 -04:00
const (
TypeStreamNextVideo RequestType = "StreamNextVideo"
TypeStreamPrevVideo RequestType = "StreamPrevVideo"
TypeQuit RequestType = "Quit"
2024-10-23 14:35:37 -04:00
)
type Request struct {
2024-10-23 17:06:19 -04:00
Type RequestType `json:"type"`
2024-10-23 14:35:37 -04:00
}
2024-10-23 17:06:19 -04:00
type Date struct {
Timestamp int64 `json:"timestamp"`
CurrentVideoPath string `json:"currentVideoPath"`
VideoList []string `json:"videoList"`
Output string `json:"output"`
2024-10-23 14:35:37 -04:00
}
2024-10-24 04:23:50 -04:00
func RequestHandler(reqType RequestType) {
switch reqType {
case TypeStreamNextVideo:
streamer.GlobalStreamer.Next()
case TypeStreamPrevVideo:
streamer.GlobalStreamer.Prev()
case TypeQuit:
streamer.GlobalStreamer.Close()
os.Exit(0)
}
}