WingMan – Diff between revs 27 and 32

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 27 Rev 32
Line 13... Line 13...
13 using MQTTnet.Extensions.ManagedClient; 13 using MQTTnet.Extensions.ManagedClient;
14 using MQTTnet.Server; 14 using MQTTnet.Server;
15 using WingMan.AutoCompletion; 15 using WingMan.AutoCompletion;
16 using WingMan.Bindings; 16 using WingMan.Bindings;
17 using WingMan.Communication; 17 using WingMan.Communication;
-   18 using WingMan.Discovery;
18 using WingMan.Lobby; 19 using WingMan.Lobby;
19 using WingMan.Properties; 20 using WingMan.Properties;
20 using WingMan.Utilities; 21 using WingMan.Utilities;
Line 21... Line 22...
21   22  
Line 28... Line 29...
28 InitializeComponent(); 29 InitializeComponent();
Line 29... Line 30...
29   30  
30 FormTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext(); 31 FormTaskScheduler = TaskScheduler.FromCurrentSynchronizationContext();
Line -... Line 32...
-   32 FormCancellationTokenSource = new CancellationTokenSource();
-   33  
-   34 // Set up discovery.
-   35 Discovery = new Discovery.Discovery(FormCancellationTokenSource, FormTaskScheduler);
31 FormCancellationTokenSource = new CancellationTokenSource(); 36 Discovery.OnPortMapFailed += OnDiscoveryPortMapFailed;
32   37  
33 // Set up autocompletion. 38 // Set up autocompletion.
34 AutoCompletion = new AutoCompletion.AutoCompletion(FormTaskScheduler, FormCancellationTokenSource.Token); 39 AutoCompletion = new AutoCompletion.AutoCompletion(FormTaskScheduler, FormCancellationTokenSource.Token);
Line 94... Line 99...
94 KeySimulator = new KeySimulator(LocalKeyBindings, MqttCommunication, FormTaskScheduler, 99 KeySimulator = new KeySimulator(LocalKeyBindings, MqttCommunication, FormTaskScheduler,
95 FormCancellationTokenSource.Token); 100 FormCancellationTokenSource.Token);
96 KeySimulator.OnMouseKeyBindingExecuting += OnMouseKeyBindingExecuting; 101 KeySimulator.OnMouseKeyBindingExecuting += OnMouseKeyBindingExecuting;
97 } 102 }
Line -... Line 103...
-   103  
98   104 private static Discovery.Discovery Discovery { get; set; }
99 private static AutoCompletion.AutoCompletion AutoCompletion { get; set; } 105 private static AutoCompletion.AutoCompletion AutoCompletion { get; set; }
Line 100... Line 106...
100 private static CancellationTokenSource FormCancellationTokenSource { get; set; } 106 private static CancellationTokenSource FormCancellationTokenSource { get; set; }
Line 123... Line 129...
123   129  
Line 124... Line 130...
124 public KeyInterceptor KeyInterceptor { get; set; } 130 public KeyInterceptor KeyInterceptor { get; set; }
Line -... Line 131...
-   131  
-   132 public KeySimulator KeySimulator { get; set; }
-   133  
-   134 public void OnDiscoveryPortMapFailed(object sender, DiscoveryFailedEventArgs args)
-   135 {
-   136 switch (args.Type)
-   137 {
-   138 case DiscoveryType.UPnP:
-   139 ActivityTextBox.AppendText(
-   140 $"{Strings.Failed_to_create_UPnP_port_mapping}{Environment.NewLine}");
-   141 break;
-   142 case DiscoveryType.PMP:
-   143 ActivityTextBox.AppendText(
-   144 $"{Strings.Failed_to_create_PMP_port_mapping}{Environment.NewLine}");
-   145 break;
125   146 }
126 public KeySimulator KeySimulator { get; set; } 147 }
127   148  
128 private void LocalCheckedListBoxBindingSourceOnListChanged(object sender, ListChangedEventArgs e) 149 private void LocalCheckedListBoxBindingSourceOnListChanged(object sender, ListChangedEventArgs e)
Line 340... Line 361...
340 if (!ValidateConnectionParameters(out var ipAddress, out var port, out var nick, out var password)) 361 if (!ValidateConnectionParameters(out var ipAddress, out var port, out var nick, out var password))
341 return; 362 return;
Line 342... Line 363...
342   363  
Line -... Line 364...
-   364 StoreConnectionAutocomplete();
-   365  
-   366 // Try to reserve port: try UPnP followed by PMP.
-   367 if (!await Discovery.CreateMapping(DiscoveryType.UPnP, port) &&
-   368 !await Discovery.CreateMapping(DiscoveryType.PMP, port))
-   369 ActivityTextBox.AppendText(
343 StoreConnectionAutocomplete(); 370 $"{Strings.Failed_creating_automatic_port_mapping_please_make_sure_the_port_is_routed_properly}{Environment.NewLine}");
344   371  
345 // Start the MQTT server. 372 // Start the MQTT server.
346 if (!await MqttCommunication 373 if (!await MqttCommunication
347 .Start(MqttCommunicationType.Server, ipAddress, port, nick, password)) 374 .Start(MqttCommunicationType.Server, ipAddress, port, nick, password))