Ensure we try to reconnect a system after a disconnect

pull/1/head
php 1 year ago
parent e9d81266bc
commit 51d1319c50

@ -1,4 +1,24 @@
using System.Windows; /*
* WhackerLink - WhackerLinkConsoleV2
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright (C) 2024 Caleb, K4PHP
*
*/
using System.Windows;
using System.Collections.Generic; using System.Collections.Generic;
using NAudio.Wave; using NAudio.Wave;

@ -173,26 +173,43 @@ namespace WhackerLinkConsoleV2
handler.OnVoiceChannelRelease += HandleVoiceRelease; handler.OnVoiceChannelRelease += HandleVoiceRelease;
handler.OnAudioData += HandleReceivedAudio; handler.OnAudioData += HandleReceivedAudio;
Task.Factory.StartNew(() => handler.OnUnitRegistrationResponse += (response) =>
{ {
handler.Connect(system.Address, system.Port); Dispatcher.Invoke(() =>
handler.OnUnitRegistrationResponse += (response) =>
{ {
Dispatcher.Invoke(() => if (response.Status == (int)ResponseType.GRANT)
{ {
if (response.Status == (int)ResponseType.GRANT) systemStatusBox.Background = new SolidColorBrush(Colors.Green);
{ systemStatusBox.ConnectionState = "Connected";
systemStatusBox.Background = new SolidColorBrush(Colors.Green); }
systemStatusBox.ConnectionState = "Connected"; else
} {
else systemStatusBox.Background = new SolidColorBrush(Colors.Red);
{ systemStatusBox.ConnectionState = "Disconnected";
systemStatusBox.Background = new SolidColorBrush(Colors.Red); }
systemStatusBox.ConnectionState = "Disconnected"; });
} };
});
}; handler.OnClose += () =>
{
Dispatcher.Invoke(() =>
{
systemStatusBox.Background = new SolidColorBrush(Colors.Red);
systemStatusBox.ConnectionState = "Disconnected";
});
Thread.Sleep(1000);
Task.Factory.StartNew(() =>
{
handler.Connect(system.Address, system.Port);
handler.SendMessage(PacketFactory.CreateUnitRegistrationRequest(system.Rid, system.Site));
});
};
Task.Factory.StartNew(() =>
{
handler.Connect(system.Address, system.Port);
handler.OnGroupAffiliationResponse += (response) => { /* TODO */ }; handler.OnGroupAffiliationResponse += (response) => { /* TODO */ };

Loading…
Cancel
Save

Powered by TurnKey Linux.