/// <summary>
/// Helper method for dependencies
/// </summary>
/// <param name="dep">The dependencies</param>
/// <param name="shouldBeOn">Should the SRE associated with this microphone be turned on or not</param>
private async void DepenedencyHelper(dynamic dep, bool shouldBeOn)
{
foreach (var mic in dep)
{
if ((string)mic.Value == "up")
{
if (mics.ContainsKey(mic.Key))
{
SpeechRecognitionEngine sre = mics[mic.Key].Sre;
if (sre.AudioState == AudioState.Stopped && mics[mic.Key].ShouldBeOn)
sre.RecognizeAsync(RecognizeMode.Multiple);
}
else
{
UDPClient client = new UDPClient(port);
client.StartClient();
AddInputMic(mic.Key, client, mic.Value, shouldBeOn);
port++;
}
await Query("microphone", "invite", new { ip = ipAddress, port = mics[mic.Key].Port }, new string[1] { mic.Key });
}
else
{
if (mics.ContainsKey(mic.Key))
{
mics[(string)mic.Key].Client.StopClient();
SpeechRecognitionEngine sre = mics[mic.Key].Sre;
if (sre.AudioState != AudioState.Stopped && shouldBeOn)
{
sre.RecognizeAsyncCancel();
Logger.GetInstance().Debug("IT STOPPED!");
}
mics.Remove(mic.Key);
}
}
}
}