Sub Class_Globals
Private Pinger As Shell
Public Destination As String
Public Attempts As Byte
Public Timeout As Int
End Sub
Public Sub Initialize(CallBack As Object, EventName As String)
Destination = "google.com"
Attempts = 4
Timeout = 200
End Sub
Private Sub DesktopDoPing()
If Attempts = 0 Then
If xui.SubExists(mCallback, mEventName & "_PingError", 1) Then
CallSub2(mCallback, mEventName & "_PingError", "Attempts must be greater than or equal to 1")
End If
Else
If xui.SubExists(mCallback, mEventName & "_PingStarted", 0) Then
CallSub(mCallback, mEventName & "_PingStarted")
End If
'Pinger.Initialize("Desktop", "ping", Array(Destination, " -w " & Timeout, " -n " & Attempts))
Pinger.Initialize("Desktop", "cmd.exe", Array("/c ", " ping ", Destination, " -w " & Timeout, " -n " & Attempts))
If Pinger.IsInitialized Then
'The execution has a lifespan calculated as "response time * attempts" + 5 seconds.
Pinger.Run((Timeout * Attempts) + 5000)
End If
End If
End Sub
Private Sub Desktop_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
Log(StdOut)
End Sub