WingMan – Diff between revs 7 and 9
?pathlinks?
Rev 7 | Rev 9 | |||
---|---|---|---|---|
Line 11... | Line 11... | |||
11 | { |
11 | { |
|
12 | public class MouseKeyBindingsSynchronizer |
12 | public class MouseKeyBindingsSynchronizer |
|
13 | { |
13 | { |
|
14 | public delegate void MouseKeyBindingsSynchronized(object sender, MouseKeyBindingsSynchronizedEventArgs e); |
14 | public delegate void MouseKeyBindingsSynchronized(object sender, MouseKeyBindingsSynchronizedEventArgs e); |
|
Line 15... | Line 15... | |||
15 | |
15 | |
|
16 | public MouseKeyBindingsSynchronizer(MouseKeyBindings mouseKeyBindings, MQTTCommunication MQTTCommunication, |
16 | public MouseKeyBindingsSynchronizer(MouseKeyBindings mouseKeyBindings, MqttCommunication mqttCommunication, |
|
17 | TaskScheduler taskScheduler, CancellationToken cancellationToken) |
17 | TaskScheduler taskScheduler, CancellationToken cancellationToken) |
|
18 | { |
18 | { |
|
19 | MouseKeyBindings = mouseKeyBindings; |
19 | MouseKeyBindings = mouseKeyBindings; |
|
20 | this.MQTTCommunication = MQTTCommunication; |
20 | MqttCommunication = mqttCommunication; |
|
21 | CancellationToken = cancellationToken; |
21 | CancellationToken = cancellationToken; |
|
Line 22... | Line 22... | |||
22 | TaskScheduler = taskScheduler; |
22 | TaskScheduler = taskScheduler; |
|
Line 23... | Line 23... | |||
23 | |
23 | |
|
Line 24... | Line 24... | |||
24 | SynchronizedMouseKeyBindings = new ConcurrentDictionary<string, List<MouseKeyBinding>>(); |
24 | SynchronizedMouseKeyBindings = new ConcurrentDictionary<string, List<MouseKeyBinding>>(); |
|
25 | |
25 | |
|
Line 26... | Line 26... | |||
26 | MQTTCommunication.OnMessageReceived += MqttCommunicationOnOnMessageReceived; |
26 | mqttCommunication.OnMessageReceived += MqttCommunicationOnOnMessageReceived; |
|
Line 27... | Line 27... | |||
27 | |
27 | |
|
Line 28... | Line 28... | |||
28 | Task.Run(Synchronize, CancellationToken); |
28 | Task.Run(Synchronize, CancellationToken); |
|
Line 29... | Line 29... | |||
29 | } |
29 | } |
|
30 | |
30 | |
|
31 | private MouseKeyBindings MouseKeyBindings { get; } |
31 | private MouseKeyBindings MouseKeyBindings { get; } |
|
Line 72... | Line 72... | |||
72 | { |
72 | { |
|
73 | do |
73 | do |
|
74 | { |
74 | { |
|
75 | await Task.Delay(1000, CancellationToken).ConfigureAwait(false); |
75 | await Task.Delay(1000, CancellationToken).ConfigureAwait(false); |
|
Line 76... | Line 76... | |||
76 | |
76 | |
|
77 | if (!MQTTCommunication.Running) |
77 | if (!MqttCommunication.Running) |
|
Line 78... | Line 78... | |||
78 | continue; |
78 | continue; |
|
79 | |
79 | |
|
80 | using (var memoryStream = new MemoryStream()) |
80 | using (var memoryStream = new MemoryStream()) |
|
81 | { |
81 | { |
|
Line 82... | Line 82... | |||
82 | MouseKeyBindingExchange.XmlSerializer.Serialize(memoryStream, |
82 | MouseKeyBindingExchange.XmlSerializer.Serialize(memoryStream, |
|
Line 83... | Line 83... | |||
83 | new MouseKeyBindingExchange(MQTTCommunication.Nick, MouseKeyBindings.Bindings)); |
83 | new MouseKeyBindingExchange(MqttCommunication.Nick, MouseKeyBindings.Bindings)); |
|
84 | |
84 | |
|
85 | memoryStream.Position = 0L; |
85 | memoryStream.Position = 0L; |
|
86 | |
86 | |
|
87 | await MQTTCommunication.Broadcast("exchange", memoryStream.ToArray()).ConfigureAwait(false); |
87 | await MqttCommunication.Broadcast("exchange", memoryStream.ToArray()).ConfigureAwait(false); |
|
88 | } |
88 | } |