Skip to content

Commit

Permalink
Initial conversion to implementing a watchdog
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Feb 18, 2024
1 parent 063722b commit 92732f1
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
28 changes: 14 additions & 14 deletions server/storage/storage.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/storage/storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ message Stored {
message Stream {
string stream = 1;
string input = 2;
bool recording = 3;
bool website = 4;
uint64 streams = 5;
string recording = 3;
string website = 4;
repeated string streams = 5;
}
6 changes: 3 additions & 3 deletions server/views/resume.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func (v *Views) ResumeFunc(c echo.Context) error {
log.Printf("accepted resume: %s", unique)

response.Response = "ACCEPTED!"
response.Website = stream.Website
response.Recording = stream.Recording
response.Streams = stream.Streams
response.Website = len(stream.Website) > 0
response.Recording = len(stream.Recording) > 0
response.Streams = uint64(len(stream.Streams))
return c.JSON(http.StatusOK, response)
}
return echo.NewHTTPError(http.StatusMethodNotAllowed, "invalid method")
Expand Down
14 changes: 7 additions & 7 deletions server/views/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func (v *Views) StartFunc(c echo.Context) error {
Error string `json:"error"`
}

recording := false
websiteStream := false
//recording := false
//websiteStream := false

if c.FormValue("website_stream") == "on" {
websiteStream = true
//websiteStream = true
if v.websiteCheck(c.FormValue("website_stream_endpoint")) {
fStart.WebsiteOut = c.FormValue("website_stream_endpoint")
} else {
Expand Down Expand Up @@ -141,7 +141,7 @@ func (v *Views) StartFunc(c echo.Context) error {
go func() {
defer wg.Done()
if c.FormValue("record") == "on" {
recording = true
//recording = true
recorderTransporter := transporter
recorderTransporter.Payload = rStart
wsResponse, err := v.wsHelper(server.Recorder, recorderTransporter)
Expand Down Expand Up @@ -194,9 +194,9 @@ func (v *Views) StartFunc(c echo.Context) error {
s, err := v.store.AddStream(&storage.Stream{
Stream: string(b),
Input: c.FormValue("stream_selector"),
Recording: recording,
Website: websiteStream,
Streams: uint64(len(streams)),
Recording: rStart.PathOut,
Website: fStart.WebsiteOut,
Streams: streams,
})
if err != nil {
log.Printf("invalid response from Forwarder for start: %s", response)
Expand Down
14 changes: 7 additions & 7 deletions server/views/startUnique.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func (v *Views) StartUniqueFunc(c echo.Context) error {
PathOut: c.FormValue("save_path"),
}

recording := false
websiteStream := false
//recording := false
//websiteStream := false

if c.FormValue("website_stream") == "on" {
websiteStream = true
//websiteStream = true
if v.websiteCheck(c.FormValue("website_stream_endpoint")) {
fStart.WebsiteOut = c.FormValue("website_stream_endpoint")
} else {
Expand Down Expand Up @@ -155,7 +155,7 @@ func (v *Views) StartUniqueFunc(c echo.Context) error {
go func() {
defer wg.Done()
if c.FormValue("record") == "on" {
recording = true
//recording = true
recorderTransporter := transporter
recorderTransporter.Payload = rStart
var wsResponse commonTransporter.ResponseTransporter
Expand Down Expand Up @@ -211,9 +211,9 @@ func (v *Views) StartUniqueFunc(c echo.Context) error {
s, err = v.store.AddStream(&storage.Stream{
Stream: unique,
Input: streamIn,
Recording: recording,
Website: websiteStream,
Streams: uint64(len(streams)),
Recording: rStart.PathOut,
Website: fStart.WebsiteOut,
Streams: streams,
})
if err != nil {
log.Printf("invalid response from Forwarder for start: %s", response)
Expand Down
6 changes: 3 additions & 3 deletions server/views/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ func (v *Views) StatusFunc(c echo.Context) error {

//nolint:staticcheck
fStatus := commonTransporter.ForwarderStatus{
Website: stream.Website,
Streams: int(stream.Streams),
Website: len(stream.Website) > 0,
Streams: len(stream.Streams),
}

var statusResponse StatusResponse
var wg sync.WaitGroup
if stream.Recording {
if len(stream.Recording) > 0 {
wg.Add(2)
go func() {
defer wg.Done()
Expand Down
6 changes: 3 additions & 3 deletions server/views/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (v *Views) StopFunc(c echo.Context) error {
_, rec := v.cache.Get(server.Recorder.String())
_, fow := v.cache.Get(server.Forwarder.String())

if (!rec && stream.Recording) && !fow {
if (!rec && len(stream.Recording) > 0) && !fow {
err = fmt.Errorf("no recorder or forwarder available")
} else if !rec && stream.Recording {
} else if !rec && len(stream.Recording) > 0 {
err = fmt.Errorf("no recorder available")
} else if !fow {
err = fmt.Errorf("no forwarder available")
Expand All @@ -69,7 +69,7 @@ func (v *Views) StopFunc(c echo.Context) error {
wg.Add(2)
go func() {
defer wg.Done()
if stream.Recording {
if len(stream.Recording) > 0 {
recorderTransporter := transporter
var wsResponse commonTransporter.ResponseTransporter
wsResponse, err = v.wsHelper(server.Recorder, recorderTransporter)
Expand Down

0 comments on commit 92732f1

Please sign in to comment.