#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private server As HttpServer
Public port As Int = 5555
Public HttpDevice As String
End Sub
Sub Service_Create
server.Initialize("Server")
server.Start(port)
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo("Http Server Attivo", "", Main)
Service.StartForeground(1, n)
Messages.Initialize
HttpDevice=""
LogColor("Server Http Avviato",Colors.Red)
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub
Sub Server_HandleRequest (Request As ServletRequest, Response As ServletResponse)
Try
If Request.Method = "POST" Then 'User pressed on the Send button
Log("Incasso HTTP in corso ")
wait for RispostaHttp (Risposta As String)
Response.SendString(Risposta)
Log("Risposta" & Risposta)
Else
Log("Non è un POST")
End If
Catch
Response.Status = 500
Log("Error serving request: " & LastException)
Response.SendString("Errore server " & LastException )
End Try
End Sub
Sub Service_Destroy
server.Stop
Service.StopForeground(1)
End Sub