|
1 |
| -// Visual Pinball Engine |
| 1 | +// Visual Pinball Engine |
2 | 2 | // Copyright (C) 2021 freezy and VPE Team
|
3 | 3 | //
|
4 | 4 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
@@ -74,36 +74,43 @@ await _switchStream.RequestStream.WriteAsync(new SwitchChanges
|
74 | 74 | private async void ReceiveCommands()
|
75 | 75 | {
|
76 | 76 | Logger.Info("Client started, retrieving commands...");
|
77 |
| - while (await _commandStream.ResponseStream.MoveNext()) { |
78 |
| - var commands = _commandStream.ResponseStream.Current; |
79 |
| - switch (commands.CommandCase) { |
80 |
| - case Commands.CommandOneofCase.None: |
81 |
| - break; |
82 |
| - case Commands.CommandOneofCase.FadeLight: |
83 |
| - OnFadeLight?.Invoke(this, commands.FadeLight); |
84 |
| - break; |
85 |
| - case Commands.CommandOneofCase.PulseCoil: |
86 |
| - OnPulseCoil?.Invoke(this, commands.PulseCoil); |
87 |
| - break; |
88 |
| - case Commands.CommandOneofCase.EnableCoil: |
89 |
| - OnEnableCoil?.Invoke(this, commands.EnableCoil); |
90 |
| - break; |
91 |
| - case Commands.CommandOneofCase.DisableCoil: |
92 |
| - OnDisableCoil?.Invoke(this, commands.DisableCoil); |
93 |
| - break; |
94 |
| - case Commands.CommandOneofCase.ConfigureHardwareRule: |
95 |
| - OnConfigureHardwareRule?.Invoke(this, commands.ConfigureHardwareRule); |
96 |
| - break; |
97 |
| - case Commands.CommandOneofCase.RemoveHardwareRule: |
98 |
| - OnRemoveHardwareRule?.Invoke(this, commands.RemoveHardwareRule); |
99 |
| - break; |
100 |
| - case Commands.CommandOneofCase.DmdFrameRequest: |
101 |
| - OnDmdFrame?.Invoke(this, commands.DmdFrameRequest); |
102 |
| - break; |
103 |
| - default: |
104 |
| - throw new ArgumentOutOfRangeException(); |
| 77 | + |
| 78 | + try { |
| 79 | + while (await _commandStream.ResponseStream.MoveNext()) { |
| 80 | + var commands = _commandStream.ResponseStream.Current; |
| 81 | + switch (commands.CommandCase) { |
| 82 | + case Commands.CommandOneofCase.None: |
| 83 | + break; |
| 84 | + case Commands.CommandOneofCase.FadeLight: |
| 85 | + OnFadeLight?.Invoke(this, commands.FadeLight); |
| 86 | + break; |
| 87 | + case Commands.CommandOneofCase.PulseCoil: |
| 88 | + OnPulseCoil?.Invoke(this, commands.PulseCoil); |
| 89 | + break; |
| 90 | + case Commands.CommandOneofCase.EnableCoil: |
| 91 | + OnEnableCoil?.Invoke(this, commands.EnableCoil); |
| 92 | + break; |
| 93 | + case Commands.CommandOneofCase.DisableCoil: |
| 94 | + OnDisableCoil?.Invoke(this, commands.DisableCoil); |
| 95 | + break; |
| 96 | + case Commands.CommandOneofCase.ConfigureHardwareRule: |
| 97 | + OnConfigureHardwareRule?.Invoke(this, commands.ConfigureHardwareRule); |
| 98 | + break; |
| 99 | + case Commands.CommandOneofCase.RemoveHardwareRule: |
| 100 | + OnRemoveHardwareRule?.Invoke(this, commands.RemoveHardwareRule); |
| 101 | + break; |
| 102 | + case Commands.CommandOneofCase.DmdFrameRequest: |
| 103 | + OnDmdFrame?.Invoke(this, commands.DmdFrameRequest); |
| 104 | + break; |
| 105 | + default: |
| 106 | + throw new ArgumentOutOfRangeException(); |
| 107 | + } |
105 | 108 | }
|
106 | 109 | }
|
| 110 | + |
| 111 | + catch(RpcException e) { |
| 112 | + Logger.Error($"Unable to retrieve commands: Status={e.Status}"); |
| 113 | + } |
107 | 114 | }
|
108 | 115 |
|
109 | 116 | public MachineDescription GetMachineDescription()
|
|
0 commit comments