@@ -89,6 +89,20 @@ public ServerControl(IButtplugServerFactory bpFactory)
8989 _log . OnLogException += ExceptionLogged ;
9090 }
9191
92+ private void SetLastError ( string aErrorMsg )
93+ {
94+ LastErrorLabel . Visibility = Visibility . Visible ;
95+ LastError . Visibility = Visibility . Visible ;
96+ LastError . Text = aErrorMsg ;
97+ }
98+
99+ private void ClearLastError ( )
100+ {
101+ LastErrorLabel . Visibility = Visibility . Hidden ;
102+ LastError . Visibility = Visibility . Hidden ;
103+ LastError . Text = string . Empty ;
104+ }
105+
92106 private void WebSocketExceptionHandler ( object aObj , [ NotNull ] UnhandledExceptionEventArgs aEx )
93107 {
94108 _toastTimer . Enabled = true ;
@@ -120,6 +134,8 @@ private void WebSocketConnectionAccepted(object aObj, [NotNull] ConnectionEventA
120134 {
121135 ConnStatus . Content = "(Connected) " + aEvent . ClientName ;
122136 DisconnectButton . IsEnabled = true ;
137+ // We've gotten a connection, clear the last error.
138+ ClearLastError ( ) ;
123139 } ) ;
124140 }
125141
@@ -162,7 +178,7 @@ private void ExceptionLogged(object aObj, [NotNull] LogExceptionEventArgs aEvent
162178 Dispatcher . InvokeAsync ( ( ) =>
163179 {
164180 // Show the error message in the app
165- LastError . Text = aEvent . ErrorMessage ;
181+ SetLastError ( aEvent . ErrorMessage ) ;
166182 } ) ;
167183 _toastTimer . Enabled = true ;
168184 }
@@ -203,6 +219,9 @@ public void StartServer()
203219 ConnStatus . Content = "(Not Connected)" ;
204220 DisconnectButton . IsEnabled = false ;
205221 ConnInfo . IsEnabled = true ;
222+
223+ // We've brought the server up, clear the error.
224+ ClearLastError ( ) ;
206225 }
207226 catch ( SocketException e )
208227 {
0 commit comments