http://192.168.1.5:8888/cgi-bin/zapTo?path=123456
request.InitializeGet(URLZap)
If HttpChanClient1.ExecuteCredentials(request,2,main.BoxUser,main.BoxPassword)=False Then Return
Sub HttpChanClient1_ResponseSuccess (Response As HttpResponse, TaskId As Int)
If taskid=2 Then
'my successive code
End If
end sub
Sub Download(JobName As String, URL As String,SkipResponse As Boolean)
If SkipResponse = True Then
HttpUtilsService.SkipResponse=True
End If
DownloadList(JobName, Array As String(URL))
End Sub
Dim SkipResponse As Boolean
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
If SkipResponse = True Then
Response_StreamFinish(True,0)
SkipResponse=False
Else
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
True, TaskId)
End If
End Sub
If main.EnigmaType="Enigma" Then
HttpUtils.Download("JOB_ZAPTO",URLZap,True) 'True=no response wanted
Else
HttpUtils.Download("JOB_ZAPTO",URLZap,False)
End If
Sub Globals
Dim b4a As String
'--------------------------------------
b4a = "http://192.168.1.60"
'--------------------------------------
bt1 = "http://192.168.1.60/c1" 'led1"
bt2 = "http://192.168.1.60/c2" 'led1 off"
bt3 = "http://192.168.1.60/c3"
bt4 = "http://192.168.1.60/c4"
bt5 = "http://192.168.1.60/c5" 'motor down"
bt6 = "http://192.168.1.60/c6" 'motor up"
bt7 = "http://192.168.1.60/c7" 'led2 up"
bt8 = "http://192.168.1.60/c8" 'led2 down"
bt9 = "http://192.168.1.60/t3"
bt10 = "http://192.168.1.60/t2"
bt11 = "http://192.168.1.60/t1"
'------------------------------------
bt111 = "http://192.168.1.60/k3"
bt112 = "http://192.168.1.60/k2"
bt113 = "http://192.168.1.60/k1"
bt114 = "http://192.168.1.60/k0"
'------------------------------------
bt115 = "http://192.168.1.60/d2"
bt116 = "http://192.168.1.60/d1"
bt117 = "http://192.168.1.60/d0"
Dim Button1 As Button
Dim EditText1 As EditText
Dim Button2 As Button
End Sub
Sub Activity_Create (FirstTime As Boolean)
Activity.LoadLayout("view1")
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", b4a)
End Sub
Sub JobDone (Job As String)
Dim s As String
If HttpUtils.IsSuccess(b4a) Then
EditText1.Text = HttpUtils.GetString(b4a)
End If
End Sub
Sub Button1_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt1)
End Sub
Sub Button2_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt2)
End Sub
Sub Button3_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt3)
End Sub
Sub Button4_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt4)
End Sub
Sub Button5_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt5)
End Sub
Sub Button6_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt6)
End Sub
Sub Button7_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt7)
End Sub
Sub Button8_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt8)
End Sub
Sub Button9_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt9)
End Sub
Sub Button10_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt10)
End Sub
Sub Button11_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt11)
End Sub
Sub ImageView1_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt111)
End Sub
Sub ImageView2_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt112)
End Sub
Sub ImageView3_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt113)
End Sub
Sub ImageView4_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt114)
End Sub
Sub ImageView5_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt115)
End Sub
Sub ImageView6_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt116)
End Sub
Sub ImageView7_Click
HttpUtils.CallbackActivity = "Main" 'Current activity name.
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.Download("Job1", bt117)
End Sub
'Version 1.04
Sub Process_Globals
Dim Tasks As List 'List of URLs to fetch.
'A map that holds the successful links.
'The links are stored as keys. The values are not used.
Dim SuccessfulUrls As Map
Dim Working As Boolean 'True when a job is still running
Dim Complete As Boolean 'True after a job has completer
Dim Job As String 'Name of the current running Job
Dim CallbackActivity As String 'Name of Activity that handles the callbacks.
Dim CallbackJobDoneSub As String 'Name of the JobDone callback sub.
Dim CallbackUrlDoneSub As String 'Name of the UrlDone callback sub.
End Sub
'Download a single resource (GET method).
Sub Download(JobName As String, URL As String)
DownloadList(JobName, Array As String(URL))
End Sub
'Downloads a list of resources (GET method).
Sub DownloadList(JobName As String, URLs As List)
If internalCheckIfCanStart(JobName) = False Then Return
Tasks = URLs
HttpUtilsService.Post = False
StartService(HttpUtilsService)
End Sub
'Sends a POST request with the given string as the post data
Sub PostString(JobName As String, URL As String, Text As String)
PostBytes(JobName, URL, Text.GetBytes("UTF8"))
End Sub
'Sends a POST request with the given file send as the post data.
Sub PostFile(JobName As String, URL As String, Dir As String, FileName As String)
If internalCheckIfCanStart(JobName) = False Then Return
Dim length As Int
If Dir = File.DirAssets Then
Log("Cannot send files from the assets folder.")
Return
End If
length = File.Size(Dir, FileName)
Dim in As InputStream
in = File.OpenInput(Dir, FileName)
If length < 1000000 Then '1mb
'There are advantages for sending the file as bytes array. It allows the Http library to resend the data
'if it failed in the first time.
Dim out As OutputStream
out.InitializeToBytesArray(length)
File.Copy2(in, Out)
HttpUtilsService.PostInputStream = Null
HttpUtilsService.PostBytes = out.ToBytesArray
Else
HttpUtilsService.PostInputStream = in
HttpUtilsService.PostLength = length
End If
Tasks = Array As String(URL)
HttpUtilsService.Post = True
StartService(HttpUtilsService)
End Sub
'Sends a POST request with the given data as the post data.
Sub PostBytes(JobName As String, URL As String, Data() As Byte)
If internalCheckIfCanStart(JobName) = False Then Return
HttpUtilsService.PostInputStream = Null
HttpUtilsService.PostBytes = Data
Tasks = Array As String(URL)
HttpUtilsService.Post = True
StartService(HttpUtilsService)
End Sub
Sub internalCheckIfCanStart(JobName As String) As Boolean
If Working Then
Log("Already working. Request ignored (" & JobName & ")")
Return False
End If
Log("Starting Job: " & JobName)
Job = JobName
Working = True
Complete = False
SuccessfulUrls.Initialize
Return True
End Sub
Sub IsSuccess(URL As String) As Boolean
Return SuccessfulUrls.ContainsKey(URL)
End Sub
'Get methods should be called only after the JobDone event or the UrlDone event.
Sub GetString(URL As String) As String
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return ""
End If
Return File.GetText(HttpUtilsService.TempFolder, SuccessfulUrls.Get(URL))
End Sub
Sub GetBitmap(URL As String) As Bitmap
Dim b As Bitmap
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return b
End If
b = LoadBitmap(HttpUtilsService.TempFolder, SuccessfulUrls.Get(URL))
Return b
End Sub
Sub GetInputStream(URL As String) As InputStream
Dim in As InputStream
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return in
End If
in = File.OpenInput(HttpUtilsService.TempFolder, SuccessfulUrls.Get(URL))
Return in
End Sub
'Version 1.04
Sub Process_Globals
Dim Tasks As List 'List of URLs to fetch.
'A map that holds the successful links.
'The links are stored as keys. The values are not used.
Dim SuccessfulUrls As Map
Dim Working As Boolean 'True when a job is still running
Dim Complete As Boolean 'True after a job has completer
Dim Job As String 'Name of the current running Job
Dim CallbackActivity As String 'Name of Activity that handles the callbacks.
Dim CallbackJobDoneSub As String 'Name of the JobDone callback sub.
Dim CallbackUrlDoneSub As String 'Name of the UrlDone callback sub.
End Sub
'Download a single resource (GET method).
Sub Download(JobName As String, URL As String)
DownloadList(JobName, Array As String(URL))
End Sub
'Downloads a list of resources (GET method).
Sub DownloadList(JobName As String, URLs As List)
If internalCheckIfCanStart(JobName) = False Then Return
Tasks = URLs
HttpUtilsService.Post = False
StartService(HttpUtilsService)
End Sub
'Sends a POST request with the given string as the post data
Sub PostString(JobName As String, URL As String, Text As String)
PostBytes(JobName, URL, Text.GetBytes("UTF8"))
End Sub
'Sends a POST request with the given file send as the post data.
Sub PostFile(JobName As String, URL As String, Dir As String, FileName As String)
If internalCheckIfCanStart(JobName) = False Then Return
Dim length As Int
If Dir = File.DirAssets Then
Log("Cannot send files from the assets folder.")
Return
End If
length = File.Size(Dir, FileName)
Dim in As InputStream
in = File.OpenInput(Dir, FileName)
If length < 1000000 Then '1mb
'There are advantages for sending the file as bytes array. It allows the Http library to resend the data
'if it failed in the first time.
Dim out As OutputStream
out.InitializeToBytesArray(length)
File.Copy2(in, Out)
HttpUtilsService.PostInputStream = Null
HttpUtilsService.PostBytes = out.ToBytesArray
Else
HttpUtilsService.PostInputStream = in
HttpUtilsService.PostLength = length
End If
Tasks = Array As String(URL)
HttpUtilsService.Post = True
StartService(HttpUtilsService)
End Sub
'Sends a POST request with the given data as the post data.
Sub PostBytes(JobName As String, URL As String, Data() As Byte)
If internalCheckIfCanStart(JobName) = False Then Return
HttpUtilsService.PostInputStream = Null
HttpUtilsService.PostBytes = Data
Tasks = Array As String(URL)
HttpUtilsService.Post = True
StartService(HttpUtilsService)
End Sub
Sub internalCheckIfCanStart(JobName As String) As Boolean
If Working Then
Log("Already working. Request ignored (" & JobName & ")")
Return False
End If
Log("Starting Job: " & JobName)
Job = JobName
Working = True
Complete = False
SuccessfulUrls.Initialize
Return True
End Sub
Sub IsSuccess(URL As String) As Boolean
Return SuccessfulUrls.ContainsKey(URL)
End Sub
'Get methods should be called only after the JobDone event or the UrlDone event.
Sub GetString(URL As String) As String
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return ""
End If
Return File.GetText(HttpUtilsService.TempFolder, SuccessfulUrls.Get(URL))
End Sub
Sub GetBitmap(URL As String) As Bitmap
Dim b As Bitmap
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return b
End If
b = LoadBitmap(HttpUtilsService.TempFolder, SuccessfulUrls.Get(URL))
Return b
End Sub
Sub GetInputStream(URL As String) As InputStream
Dim in As InputStream
If IsSuccess(URL) = False Then
Log("Task not completed successfully.")
Return in
End If
in = File.OpenInput(HttpUtilsService.TempFolder, SuccessfulUrls.Get(URL))
Return in
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?