Hiya all,
I've replaces Http with OkHttp and everything works well. I do have a question though.
With Http I did the following.
But with OkHttp I do it this way, it works but I'm not happy with my solution. The DoEvents is annoying me.
Basically my question is how can I make the above 'Response As OkHttpResponse' shorter, I know I'm doing this the long way.
Cheers...
I've replaces Http with OkHttp and everything works well. I do have a question though.
With Http I did the following.
B4X:
Sub HC_ResponseSuccess(Response As HttpResponse, TaskId As Int)
ProjectCode.IPAddress = Response.GetString("UTF8")
Log(Response.GetString("UTF8")) 'Returns contents
End Sub
B4X:
Sub HC_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Dim HTMLContents As OutputStream
HTMLContents.InitializeToBytesArray(0)
Response.GetAsynchronously("Contents", HTMLContents, True, TaskId)
DoEvents 'Without the DoEvents the BytesToString below returns an empty string.
ProjectCode.IPAddress = BytesToString(HTMLContents.ToBytesArray, 0, HTMLContents.ToBytesArray.Length, "UTF-8")
Log(BytesToString(HTMLContents.ToBytesArray, 0, HTMLContents.ToBytesArray.Length, "UTF-8"))
End Sub
Cheers...