Android Question B4A and jRDC2 - Check if server is online

h725

Member
Licensed User
Longtime User
Hello everybody,

I am stuck with an obviously simple task. I searched the forum but I did not find a
satisfying solution. I am working with:
B4A (Clientside)
B4J(Serverside)
When I start the B4A app I would like to check if I can reach the B4J - jRDC2 Server.

Kind regards
h725
 

José J. Aguilar

Expert
Licensed User
The computer may respond correctly, but the jRDC2 server may be turned off
Ups, you're right.

So maybe you can make a request to the jRDC2 server when you start the app and check for the answer.
Not tested.

B4X:
Public Sub CheckjRDC2 (Command As String, parameters() As String) As ResumableSub
    Dim Answer As Map
    Answer.Initialize
    Dim cmd As DBCommand = CreateCommand(Command, parameters)
    Dim j As HttpJob = CreateRequest.ExecuteBatch(Array(cmd), Null)
    Wait For(j) JobDone(j As HttpJob)
    If j.Success Then
        Log("successfully!")
    else
        Log("there was some problem")
    End If
    Answer.Put("Success",j.Success)
    Answer.Put("Error", j.ErrorMessage)
    j.Release
    Return Answer
End Sub


'Later, you can do something like
        Wait For(CheckjRDC2("testSQL", Null)) Complete (Answer As Map)
        If Answer.Get("Success") Then
           Log("The jRDC2 is working")
        Else
               Log("There was some problem: " & Answer.get("Error")
        End If
 
Upvote 0
Top