Sub Class_Globals
Type tpePing (Success As Boolean, toHost As String, toIP As String, fromDest As String, mapResponse As Map, mapStatistics As Map)
Public pingResult As tpePing
Private Pinger As SimplePing
End Sub
Public Sub Start()
#If B4A
pingResult = B4APing
#Else If B4J
pingResult = B4JPing
#Else If B4I
pingResult = B4IPing
#End If
End Sub
Private Sub B4IPing() As tpePing
pingResult.toHost = Destination
iOSDoPing
Return pingResult
End Sub
Private Sub iOSDoPing()
Dim PingerResult As ResumableSub = PingerDoPing
If PingerResult.IsInitialized And PingerResult.Completed Then
For i = 1 To Attempts
Pinger.Send
Wait For Pinger_PacketSent (SequenceNumber As Int, Success As Boolean)
Log("sent: " & SequenceNumber & ": " & Success)
Sleep(Timeout)
Next
icmp_seq.Put(SequenceNumber.As (Byte), DateTime.Now - dblTStart)
Else
If xui.SubExists(mCallback, mEventName & "_PingError", 1) Then
CallSub2(mCallback, mEventName & "_PingError", LastException)
End If
End If
Pinger.Stop
If xui.SubExists(mCallback, mEventName & "_PingFinished", 0) Then
CallSub(mCallback, mEventName & "_PingFinished")
End If
End Sub
Private Sub PingerDoPing() As ResumableSub
Pinger.Initialize("iOSPing", Destination)
Pinger.Start
Wait For Pinger_Start (Success As Boolean)
'Execution never continues after this line, even with the modification I made based on the shared link of how Wait For/ResumableSub works.
pingResult.Success = Success
Return Success
End Sub