I Had an app working good until I recently tried re-compiling and found out that the http library is no longer supported. I tried OKHttp, however I now get an error when I try to use Response.GetString("UTF8"). I also tried HttpUtils2, but couldn’t figure out how to do what I need to do with that either.
I have a Status textfile (homestatus.txt) on a web-server that gets updated constantly. All I am trying to do is read it into a string so that I can know the status as it changes. The Status is read on a timer.
Does anyone know why and when GetString was removed and if I can go back to using it or not. Or even better, how to do what I need to do with HttpUtils2?
Thanks,
Jim
Following code is what used to work:
Globals:
DimHttpReqAsHttpRequest
DimHttpCAsHttpClient
Sub Get_HTTP_Status
HttpReq.InitializeGet("http://" & IPaddress & "/homestatus.txt")
HttpC.Execute(HttpReq, 1)
End Sub
Sub Activity_Create(FirstTime AsBoolean)
Activity.LoadLayout("Alarm_Control_1")
tmrIP.Initialize("tmrIP", 500)
tmrIP.Enabled = True
If FirstTime Then
hc.Initialize("http")
Get_HTTP_Status
EndIf
End Sub
Sub tmrIP_Tick
Get_HTTP_Status
End Sub
Sub hc_ResponseError (Response AsHttpResponse, Reason AsString, StatusCode AsInt, TaskId AsInt)
Str = "Error: " & Reason & " " & StatusCode
If Response <> NullThen
Response.Release
EndIf
End Sub
Sub http_responsesuccess(Response AsHttpResponse, TaskId AsInt)
Str = Response.GetString("UTF8")
.
.
.
End Sub
I have a Status textfile (homestatus.txt) on a web-server that gets updated constantly. All I am trying to do is read it into a string so that I can know the status as it changes. The Status is read on a timer.
Does anyone know why and when GetString was removed and if I can go back to using it or not. Or even better, how to do what I need to do with HttpUtils2?
Thanks,
Jim
Following code is what used to work:
Globals:
DimHttpReqAsHttpRequest
DimHttpCAsHttpClient
Sub Get_HTTP_Status
HttpReq.InitializeGet("http://" & IPaddress & "/homestatus.txt")
HttpC.Execute(HttpReq, 1)
End Sub
Sub Activity_Create(FirstTime AsBoolean)
Activity.LoadLayout("Alarm_Control_1")
tmrIP.Initialize("tmrIP", 500)
tmrIP.Enabled = True
If FirstTime Then
hc.Initialize("http")
Get_HTTP_Status
EndIf
End Sub
Sub tmrIP_Tick
Get_HTTP_Status
End Sub
Sub hc_ResponseError (Response AsHttpResponse, Reason AsString, StatusCode AsInt, TaskId AsInt)
Str = "Error: " & Reason & " " & StatusCode
If Response <> NullThen
Response.Release
EndIf
End Sub
Sub http_responsesuccess(Response AsHttpResponse, TaskId AsInt)
Str = Response.GetString("UTF8")
.
.
.
End Sub