WingMan

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 31  →  ?path2? @ 32
/trunk/WingMan/WingManForm.cs
@@ -15,6 +15,7 @@
using WingMan.AutoCompletion;
using WingMan.Bindings;
using WingMan.Communication;
using WingMan.Discovery;
using WingMan.Lobby;
using WingMan.Properties;
using WingMan.Utilities;
@@ -30,6 +31,10 @@
FormTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
FormCancellationTokenSource = new CancellationTokenSource();
 
// Set up discovery.
Discovery = new Discovery.Discovery(FormCancellationTokenSource, FormTaskScheduler);
Discovery.OnPortMapFailed += OnDiscoveryPortMapFailed;
 
// Set up autocompletion.
AutoCompletion = new AutoCompletion.AutoCompletion(FormTaskScheduler, FormCancellationTokenSource.Token);
AutoCompletion.OnSaveFailed += AutoCompletionOnSaveFailed;
@@ -96,6 +101,7 @@
KeySimulator.OnMouseKeyBindingExecuting += OnMouseKeyBindingExecuting;
}
 
private static Discovery.Discovery Discovery { get; set; }
private static AutoCompletion.AutoCompletion AutoCompletion { get; set; }
private static CancellationTokenSource FormCancellationTokenSource { get; set; }
 
@@ -125,6 +131,21 @@
 
public KeySimulator KeySimulator { get; set; }
 
public void OnDiscoveryPortMapFailed(object sender, DiscoveryFailedEventArgs args)
{
switch (args.Type)
{
case DiscoveryType.UPnP:
ActivityTextBox.AppendText(
$"{Strings.Failed_to_create_UPnP_port_mapping}{Environment.NewLine}");
break;
case DiscoveryType.PMP:
ActivityTextBox.AppendText(
$"{Strings.Failed_to_create_PMP_port_mapping}{Environment.NewLine}");
break;
}
}
 
private void LocalCheckedListBoxBindingSourceOnListChanged(object sender, ListChangedEventArgs e)
{
// Check items
@@ -342,6 +363,12 @@
 
StoreConnectionAutocomplete();
 
// Try to reserve port: try UPnP followed by PMP.
if (!await Discovery.CreateMapping(DiscoveryType.UPnP, port) &&
!await Discovery.CreateMapping(DiscoveryType.PMP, port))
ActivityTextBox.AppendText(
$"{Strings.Failed_creating_automatic_port_mapping_please_make_sure_the_port_is_routed_properly}{Environment.NewLine}");
 
// Start the MQTT server.
if (!await MqttCommunication
.Start(MqttCommunicationType.Server, ipAddress, port, nick, password))