B4J Question SOLVED: Multiple HTTP jobdone handlers

bdunkleysmith

Active Member
Licensed User
Longtime User
All of the examples I've seen for getting data are of this format:

B4X:
Sub Button_MouseClicked (EventData As MouseEvent)
    Dim job As HttpJob
    job.Initialize("GetData", Me)
    job.Download(Page)
End Sub
 
Sub JobDone(Job As HttpJob)
    If Job.Success Then
        Log(Job.GetString)
    Else
        Log("Job Error: " & Job.ErrorMessage)
    End If
    Job.ReleaseEnd
Sub

However I want to handle downloaded data from two URLs in diferent ways, eg. one is JSON while the other is HTML and so obvioulsy need two different jobdone handlers.

I presume I need to use the second parameter of the Initialize member given the documentation describes it as the TargetModule - The activity or service that will handle the JobDone event.

So how do I point to the two different jobdone event handlers?
 

bdunkleysmith

Active Member
Licensed User
Longtime User
I realized I should just initialize each HTTP job with a unique name and use that name in the Sub JobDone to distinguish how to handle the returned result.
 
Upvote 0
Top