B4J Question Data Collection Solution Question.

Uitenhage

Member
Licensed User
Longtime User
1: In post #47 of this Tutorial https://www.b4x.com/android/forum/t...olution-device-desktop-and-web-reports.37254/ Erel says that the example is old and no longer recommended. Is there a newer example of a B4A, B4J Desktop, and B4J Server Data collection app?

2: In the app above is it possible to control the server from the desktop app (on the same machine) using jShell library to launch the server and a HTTP Handler to stop it? I tried by copying snippets from the examples but the sh_ProcessCompleted never fires.
B4X:
Sub btnStartServer_Click
    If ServerStarted =  False Then
        sh.Initialize("sh", "java" , Array As String("-jar", "C:\Dropbox\B4x\CrossPlatform\Beeps\Server\Objects\BeepsServer.jar"))
        sh.Run(-1)
        ServerStarted = True
        SetButtons(ServerStarted)
    End If
End Sub
Sub sh_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    Log($"sh_ProcessCompleted:${Success}, ${ExitCode}"$ )
    If Success And ExitCode = 0 Then
        Log(StdOut)
        btnShowAll_Action        'show existing data
        ServerStarted = True
        SetButtons(ServerStarted)
    Else
        Log("sh_ProcessCompleted:Error: " & StdErr)
    End If
End Sub

Thanks,

Jim
 

DonManfred

Expert
Licensed User
Longtime User
but the sh_ProcessCompleted never fires.
is BeepsServer.jar supposed to end after its work? If BeepsServer is a server then it is the expected behaviour NOT to end and due to this hopefully never raise the sh_ProcesCompleted...

sh_Processcompleted is fired when the process crashes or ends.
 
Last edited:
Upvote 0

Uitenhage

Member
Licensed User
Longtime User
Thanks for the quick response.

BeepsServer is a copy of the DataCollectionServer example. I added a handler to process a '/endserver' message that just does an ExitApplication but I still don't get the ProcessCompleted. Is there a way to know that the server start was successful?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
When you stop your server via the /endserver URL, ProcessCompleted should be raised (since it is completed at that point).
 
Upvote 0
Top