forked from Mercury/2dxAutoClip
Improve ticker handling to stop recording
This commit is contained in:
parent
426268b512
commit
1e8fe94e3e
|
@ -32,8 +32,8 @@ class Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task ConnectWebSocket()
|
private static async Task ConnectWebSocket()
|
||||||
{
|
{
|
||||||
var tickerUri = new Uri($"ws://{WebsocketAddress}:{WebsocketPort}");
|
var tickerUri = new Uri($"ws://{WebsocketAddress}:{WebsocketPort}");
|
||||||
var reconnecting = false;
|
var reconnecting = false;
|
||||||
|
|
||||||
|
@ -42,6 +42,9 @@ class Program
|
||||||
var isRecording = false;
|
var isRecording = false;
|
||||||
var currentSongName = string.Empty;
|
var currentSongName = string.Empty;
|
||||||
|
|
||||||
|
// Flag to track if we need to check for "MUSIC SELECT!!"
|
||||||
|
var shouldCheckForMusicSelect = false;
|
||||||
|
|
||||||
using var clientWebSocket = new ClientWebSocket();
|
using var clientWebSocket = new ClientWebSocket();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -91,10 +94,21 @@ class Program
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRecording || (!message.EndsWith("CLEAR!") && !message.EndsWith("FAILED.."))) continue;
|
if (isRecording)
|
||||||
|
{
|
||||||
|
if (shouldCheckForMusicSelect && message.Contains("MUSIC SELECT!!"))
|
||||||
|
{
|
||||||
Console.WriteLine("Stopping recording...");
|
Console.WriteLine("Stopping recording...");
|
||||||
StopRecording(currentSongName);
|
StopRecording(currentSongName);
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
|
shouldCheckForMusicSelect = false;
|
||||||
|
}
|
||||||
|
else if (message.EndsWith("CLEAR!") || message.EndsWith("FAILED.."))
|
||||||
|
{
|
||||||
|
// Set the flag to check the next message for "MUSIC SELECT!!"
|
||||||
|
shouldCheckForMusicSelect = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reconnecting)
|
if (reconnecting)
|
||||||
|
@ -102,7 +116,8 @@ class Program
|
||||||
await Task.Delay(10000);
|
await Task.Delay(10000);
|
||||||
await ConnectWebSocket();
|
await ConnectWebSocket();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void StartRecording(string songName)
|
private static void StartRecording(string songName)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue