Skip to content

Commit eb6bfc6

Browse files
committed
Fix logged in state, logging in logic
- Relocated the Login() call back into the UPS class to keep logic and exceptions out of the WinNUT form (fixes connected notifications not appearing on reconnect) - Properly unset logged in flag when disconnecting. From my limited testing, the NUT server does not care how you disconnect from it - you'll always be able to log back in.
1 parent ca65848 commit eb6bfc6

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

WinNUT_V2/WinNUT-Client/WinNUT.vb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,6 @@ Public Class WinNUT
402402
LogFile.LogTracing("Connection to Nut Host Established", LogLvl.LOG_NOTICE, Me,
403403
String.Format(StrLog.Item(AppResxStr.STR_LOG_CONNECTED),
404404
upsConf.Host, upsConf.Port))
405-
406-
If Not String.IsNullOrEmpty(upsConf.Login) Then
407-
UPS_Device.Login()
408-
End If
409405
End Sub
410406

411407
Private Sub ConnectionError(sender As UPS_Device, ex As Exception) Handles UPS_Device.ConnectionError

WinNUT_V2/WinNUT-Client_Common/Nut_Socket.vb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ Public Class Nut_Socket
128128
Query_Data("LOGOUT")
129129
End If
130130

131+
_isLoggedIn = False
132+
131133
If WriterStream IsNot Nothing Then
132134
WriterStream.Dispose()
133135
End If

WinNUT_V2/WinNUT-Client_Common/UPS_Device.vb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ Public Class UPS_Device
144144
Update_Data.Start()
145145
RaiseEvent Connected(Me)
146146

147+
If Not String.IsNullOrEmpty(Nut_Config.Login) Then
148+
Login()
149+
End If
150+
147151
Catch ex As NutException
148152
' This is how we determine if we have a valid UPS name entered, among other errors.
149153
RaiseEvent EncounteredNUTException(Me, ex)

0 commit comments

Comments
 (0)