mirror of
https://github.com/onyx-and-iris/gobs-cli.git
synced 2025-05-20 16:10:26 +01:00
add stream start/stop output
This commit is contained in:
parent
dd0bbfc0da
commit
6e25927bc1
28
stream.go
28
stream.go
@ -17,10 +17,22 @@ type StreamStartCmd struct{} // size = 0x0
|
|||||||
|
|
||||||
// Run executes the command to start streaming.
|
// Run executes the command to start streaming.
|
||||||
func (cmd *StreamStartCmd) Run(ctx *context) error {
|
func (cmd *StreamStartCmd) Run(ctx *context) error {
|
||||||
_, err := ctx.Client.Stream.StartStream()
|
// Check if the stream is already active
|
||||||
|
status, err := ctx.Client.Stream.GetStreamStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if status.OutputActive {
|
||||||
|
fmt.Fprintln(ctx.Out, "Stream is already active.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ctx.Client.Stream.StartStream()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintln(ctx.Out, "Streaming started successfully.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,10 +41,22 @@ type StreamStopCmd struct{} // size = 0x0
|
|||||||
|
|
||||||
// Run executes the command to stop streaming.
|
// Run executes the command to stop streaming.
|
||||||
func (cmd *StreamStopCmd) Run(ctx *context) error {
|
func (cmd *StreamStopCmd) Run(ctx *context) error {
|
||||||
_, err := ctx.Client.Stream.StopStream()
|
// Check if the stream is already inactive
|
||||||
|
status, err := ctx.Client.Stream.GetStreamStatus()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if !status.OutputActive {
|
||||||
|
fmt.Fprintln(ctx.Out, "Stream is already inactive.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = ctx.Client.Stream.StopStream()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintln(ctx.Out, "Streaming stopped successfully.")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user