File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ pub struct State {
3333pub struct BelaState {
3434 online : bool ,
3535 is_streaming : bool ,
36+ restart : bool ,
3637 config : Option < belabox:: messages:: Config > ,
3738 netif : Option < HashMap < String , belabox:: messages:: Netif > > ,
3839 sensors : Option < belabox:: messages:: Sensors > ,
@@ -156,6 +157,18 @@ async fn handle_belabox_messages(
156157 Message :: Status ( status) => {
157158 let mut lock = bela_state. write ( ) . await ;
158159 lock. is_streaming = status. is_streaming ;
160+
161+ if lock. restart {
162+ lock. restart = false ;
163+
164+ if let Some ( config) = & lock. config {
165+ let request = belabox:: requests:: Start :: from ( config. to_owned ( ) ) ;
166+ belabox. start ( request) . await ;
167+
168+ let msg = "BB: Reboot successful, starting the stream" . to_string ( ) ;
169+ twitch. send ( msg) . await ;
170+ }
171+ }
159172 }
160173 Message :: Notification ( notification) => {
161174 if monitor. notifications {
@@ -316,6 +329,24 @@ async fn handle_twitch_messages(
316329 format ! ( "{}, Total: {} kbps" , interfaces, total_bitrate)
317330 }
318331 BotCommand :: Restart => {
332+ let is_streaming = {
333+ let mut lock = bela_state. write ( ) . await ;
334+
335+ if lock. restart {
336+ continue ;
337+ }
338+
339+ if lock. is_streaming {
340+ lock. restart = true ;
341+ }
342+
343+ lock. is_streaming
344+ } ;
345+
346+ if is_streaming {
347+ belabox. stop ( ) . await ;
348+ }
349+
319350 belabox. restart ( ) . await ;
320351 "Rebooting BELABOX" . to_string ( )
321352 }
You can’t perform that action at this time.
0 commit comments