Hi
I have a B4A application as a remote client. It has a Webview1 open /app/index.html from remote application(B4J). The index.html will send "b4j_raiseEvent" to B4j every 1 sec. I test it OK in firefox browser.
Why i cann't do it with webview of the B4A ?
p.s Websocket is work !
$(function() {
setInterval(function(){b4j_raiseEvent("datas_refresh", {})},1000);
});
B4j code
B4a Code
Html page code
I have a B4A application as a remote client. It has a Webview1 open /app/index.html from remote application(B4J). The index.html will send "b4j_raiseEvent" to B4j every 1 sec. I test it OK in firefox browser.
Why i cann't do it with webview of the B4A ?
p.s Websocket is work !
$(function() {
setInterval(function(){b4j_raiseEvent("datas_refresh", {})},1000);
});
B4j code
B4X:
Private Sub datas_refresh(Params As Map)
Dim jt1,jt2,jt3 As JQueryElement
Dim n1 As Int=0
Dim s1 As String = DateTime.Date(DateTime.now)&" "&DateTime.time(DateTime.now)
ws.GetElementById("update1").SetText("update : " & s1)
For i=1 To 8
jt1 = ws.GetElementById("low"&i)
jt2 = ws.GetElementById("tmp"&i)
jt3 = ws.GetElementById("high"&i)
jt1.SetHtml(cell(16,NumberFormat(Main.plc_v0(n1+1),0,3)))
jt2.SetHtml(cell(16,NumberFormat(Main.plc_v0(n1+0),0,3)))
jt3.SetHtml(cell(16,NumberFormat(Main.plc_v0(n1+2),0,3)))
If Main.plc_v2(i-1)=0 Then ' normal
jt2.SetCSS("background-color","")
jt2.SetCSS("color","black")
else if Main.plc_v2(i-1)>0 Then ' high
jt2.SetCSS("background-color","#F73A1A")
jt2.SetCSS("color","#FFFFFF")
Else ' low
jt2.SetCSS("background-color","#FFFF5B")
jt2.SetCSS("color","black")
End If
n1=n1+3
Next
End Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
If FirstTime Then
WebView1.Initialize("webview1")
Activity.AddView(WebView1,0dip,100dip,100%x, 100%y)
wsh.Initialize(Me, "wsh")
End If
End Sub
HTML:
$( document ).ready(function() {
b4j_connect("/app/ws");
});
$(function() {
setInterval(function(){b4j_raiseEvent("datas_refresh", {})},1000);
});