$clacks->doNetwork(); # No data packet for more than 10 seconds, send a "OBS Version" request *once* if(!$sendobsversionrequest && (time - $lastobspacket) > 10) { print "No heartbeat from OBS, requesting livetick as a backup measure\n"; my %request = ( 'request-type' => 'GetVersion', 'message-id' => 'rand' . int(rand(1_000_000)), ); my $outframe = $frame->new(buffer => encode_json(\%request), type => 'text', masked => 1)->to_bytes; syswrite($sock, $outframe); $sendobsversionrequest = 1; } # No data packet for more than 20 seconds and we already send a version request! # We are pretty sure that OBS is not available. So notify display, and shut down program cleanly # (will be externally restarted by bash script) if($sendobsversionrequest && (time - $lastobspacket) > 20) { print "Can't get info from OBS\n"; $clacks->set('OBS::Alive', 0); for(1..10) { $clacks->doNetwork(); sleep(0.1); } $clacks = undef; exit(0); }