mirror of
https://github.com/cheveguerra/Pusher_2.0.git
synced 2026-04-17 19:37:05 +00:00
Cambios en como se reciben y reacciona a actualizaciones.
This commit is contained in:
@@ -32,49 +32,74 @@ Sub Service_Start (StartingIntent As Intent)
|
||||
End Sub
|
||||
|
||||
Sub fm_MessageArrived (Message As RemoteMessage)
|
||||
Log("Mensaje recibido")
|
||||
Log($"Message data: ${Message.GetData}"$)
|
||||
Log($"Pusher - Mensaje recibido: ${Message.GetData}"$)
|
||||
' Log($"Message data: ${Message.GetData}"$)
|
||||
|
||||
'Si recibimos Pong, lo agregamos a la lista de dispositivos activos
|
||||
If Message.GetData.ContainsKey("t") And Message.GetData.Get("t") = "pong" Then
|
||||
Log("Recibimos pong "&Message.GetData.Get("d"))
|
||||
Log("Pusher - Recibimos pong "&Message.GetData.Get("d"))
|
||||
If Main.dispositivos.ContainsKey(Message.GetData.Get("d")) Then
|
||||
Dim dMap As Map = Main.dispositivos.Get(Message.GetData.Get("d"))
|
||||
Dim dispData As Map = dMap
|
||||
Else
|
||||
Dim dispData As Map = CreateMap("coords": "0,0", "d": Message.GetData.Get("d"),"v": Message.GetData.Get("v"), "w": Message.GetData.Get("w"))
|
||||
End If
|
||||
Log("** "&dispData)
|
||||
' Log("** "&dispData)
|
||||
Main.dispositivos.Put(Message.GetData.Get("d"), dispData)
|
||||
End If
|
||||
|
||||
'Si el mensaje es de ubicacion recibida
|
||||
If Message.GetData.ContainsKey("t") And (Message.GetData.Get("t") = "u" Or Message.GetData.Get("t") = "au") Then
|
||||
Log("Recibimos ubicacion")
|
||||
Log("Pusher - Recibimos ubicacion")
|
||||
Private ubi As Location
|
||||
Log("Llamamos UbicacionRecibida")
|
||||
If Message.GetData.Get("t") = "au" Then
|
||||
' Log("Llamamos UbicacionRecibida")
|
||||
If Message.GetData.Get("t") = "au" Or Message.GetData.Get("t") = "u" Then
|
||||
' ToastMessageShow("Ubicacion recibida:"&Message.GetData.Get("body"),False)
|
||||
Private coords() As String = Regex.split(",", Message.GetData.Get("body"))
|
||||
ubi.Initialize
|
||||
ubi.Latitude = coords(0)
|
||||
ubi.Longitude = coords(1)
|
||||
If Message.GetData.Get("body") <> "" Then
|
||||
ubi.Latitude = coords(0)
|
||||
ubi.Longitude = coords(1)
|
||||
Else
|
||||
ubi.Latitude = 0
|
||||
ubi.Longitude = 0
|
||||
End If
|
||||
' ubi.Longitude = coords(1)
|
||||
Private c As Cursor = db.ExecQuery("select * from geocercas") 'Traemos las geocercas
|
||||
Private estaGC As Location
|
||||
Private enGoecerca As Boolean = False
|
||||
Private nuevoEnGoecerca As Boolean = False
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
estaGC.Initialize
|
||||
estaGC.Latitude = c.GetString("lat")
|
||||
estaGC.Longitude = c.GetString("lon")
|
||||
Log(ubi & "|" & estaGC)
|
||||
Log(ubi.DistanceTo(estaGC))
|
||||
' Log(ubi & "|" & estaGC)
|
||||
' Log(ubi.DistanceTo(estaGC))
|
||||
If ubi.DistanceTo(estaGC) < 300 Then 'Revisamos si la ubicaccion recibida esta dentro de alguna geocerca.
|
||||
' ToastMessageShow($"Dentro de ${c.GetString("nombre")}"$, False)
|
||||
Subs.notiHigh("Dentro de Geocerca", $"${Message.GetData.Get("d")} esta dentro de ${c.GetString("nombre")}"$, 777, "Main")
|
||||
enGoecerca = True
|
||||
If Not(Starter.dentroDeGeocerca.ContainsKey(Message.GetData.Get("d"))) Then
|
||||
Starter.dentroDeGeocerca.Put(Message.GetData.Get("d"), c.GetString("nombre"))
|
||||
nuevoEnGoecerca = True
|
||||
End If
|
||||
' Log(nuevoEnGoecerca)
|
||||
' notiBigText("Dentro de Geocerca", $"${Message.GetData.Get("d")} esta dentro de ${c.GetString("nombre")}"$, 777, "Main")
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
If Not(enGoecerca) Then
|
||||
Starter.dentroDeGeocerca.Remove(Message.GetData.Get("d"))
|
||||
' Log(Starter.dentroDeGeocerca)
|
||||
End If
|
||||
Private textoNoti As String = ""
|
||||
For Each key As String In Starter.dentroDeGeocerca.Keys
|
||||
' Log(Starter.dentroDeGeocerca.Get(key))
|
||||
textoNoti = $"${textoNoti}${CRLF}${key} - ${Starter.dentroDeGeocerca.Get(key)} "$
|
||||
Next
|
||||
If nuevoEnGoecerca Then notiBigText("Geocercas", $"${textoNoti}"$, 777, "Main")
|
||||
' LogColor("****** " & Starter.dentroDeGeocerca, Colors.blue)
|
||||
' Subs.notiHigh("Dentro de Geocerca", $"${Message.GetData.Get("d")} esta dentro de ${c.GetString("nombre")}"$, 777, "Main")
|
||||
End If
|
||||
CallSub2(Main, "ubicacionRecibida", Message.GetData)
|
||||
@@ -99,6 +124,17 @@ Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
|
||||
Sub notiBigText(title2 As String, body2 As String, id2 As String, act As Object)
|
||||
Dim smiley As Bitmap = LoadBitmapResize(File.DirAssets, "logo_keymon.png", 24dip, 24dip, False)
|
||||
Dim n As NB6
|
||||
n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(smiley)
|
||||
' Dim cs As CSBuilder
|
||||
n.BigTextStyle("Geocercas", "", "")
|
||||
n.OnGoing(True)
|
||||
' n.SetDefaults(true, True, True)
|
||||
n.Build(title2, body2, "tag", act).Notify(id2)
|
||||
End Sub
|
||||
|
||||
Sub descomprimeRuta
|
||||
Dim su As StringUtils
|
||||
Dim decompressedbytes() As Byte = su.DecodeBase64(Main.base64)
|
||||
|
||||
Reference in New Issue
Block a user