﻿B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=11.2
@EndOfDesignText@
Sub Class_Globals
	Public mb_conectado As Boolean = False
	Public mdt_fecha_control_conectado As Long = 0
	Dim msObjeto As String = "clsControlConectividad"
	
	Private ls_funcion,ls_funcion_err,ls_modulo As String
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize (ms_funcion As String, ms_funcion_err As String, ms_modulo As String)
	
	ls_funcion = ms_funcion
	ls_funcion_err = ms_funcion_err
	ls_modulo = ms_modulo
		
End Sub


Public Sub gsub_control_conectividad 

	Dim lo_job As HttpJob

	mb_conectado = True

	If mdt_fecha_control_conectado < DateTime.Now Then
		mb_conectado = False
		Try
			lo_job.Initialize(msObjeto & "_control_conexion", msObjeto) ', msObjeto)
			lo_job.GetRequest.Timeout = 500000
			lo_job.Download("http://www.google.com")
			
			Wait For(lo_job) JobDone  (lo_job As HttpJob)
			
			If lo_job.Success Then
				mb_conectado = True
			End If
			lo_job.Release

		Catch
			Log(DateTime.Time(DateTime.Now) & " : " & LastException)
		End Try

		If lo_job <> Null Then
			If lo_job.IsInitialized Then
				lo_job.Release
			End If
		End If

		Dim lo_per As Period
		lo_per.Initialize
		If mb_conectado = False Then
			lo_per.Seconds = 5
		Else
			lo_per.Seconds = 20
		End If
		mdt_fecha_control_conectado = DateUtils.AddPeriod(DateTime.Now, lo_per)

	End If


	If mb_conectado Then
		
		If ls_funcion <> "" Then
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
			CallSubDelayed(ls_modulo, ls_funcion)
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		
		End If
	Else
		If ls_funcion_err <> "" Then
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
			
			CallSubDelayed(ls_modulo, ls_funcion_err)
			''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
		End If
	End If

End Sub