Hi, I have a situation where I have 10 clients(PC) connected to my app with Sqlite records. I'm using xbees(wireless) for each clients for communications(because of short distance). I'm seeing problems occurring like a delay in response time or garbage data coming from the android device. I placed a small delay whenever clients request for data for process but it needs more improvement. Is there a way to make the process flow like FIFO but with a delay to let the first query finish before another is rendered? Or buffer all data from sqlite so that incoming request need not have to directly call the database when it's busy processing the first inquiry? Please give advice. I apologize if I'm not clear on what I'm saying.
Thanks in advance..
This the code part when an incoming reuqest from clients
Thanks in advance..
This the code part when an incoming reuqest from clients
B4X:
Sub astreams_NewText(Text As String)
Dim searchDel,DelSrch,mydelaybuffer As String
Dim dataReceive As String
dataReceive = ""
dataReceive = Text.Trim
If dataReceive.Length > 1 AND dataReceive.Length < 9 Then
If dataReceive.Length > 3 AND dataReceive.Length < 9 Then
mydelaybuffer = dataReceive.SubString2(0,3)
If mydelaybuffer = "@D#" OR mydelaybuffer = "@D$" OR mydelaybuffer = "@D%" OR mydelaybuffer = "@D^" OR mydelaybuffer = "@D&" OR mydelaybuffer = "@D*" OR mydelaybuffer = "@D(" OR mydelaybuffer = "@D)" OR mydelaybuffer = "@D-" OR mydelaybuffer = "@D+" Then
Delay(150)
'Delay(150)
End If
End If
End If
If DelSrch = "@D#" Then '--Delete from Counter 1
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qp FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@#" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF#" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D$" Then '--Delete from Counter 2
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qp FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250) ' 250
DBUtils.ExecuteMap(SQL, "DELETE FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@$" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF$" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D%" Then '--Delete from Counter 3
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qp FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@%" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF%" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D^" Then '--Delete from Counter 4
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qp FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quep WHERE qp = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@^" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF^" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D&" Then '--Delete from Counter 5
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qn FROM Quen WHERE qn = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quen WHERE qn = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@&" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF&" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D*" Then '--Delete from Counter 6
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qn FROM Quen WHERE qn = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quen WHERE qn = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@*" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF*" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D(" Then '--Delete from Counter 7
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qr FROM Quer WHERE qr = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quer WHERE qr = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@(" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF(" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D)" Then '--Delete from Counter 8
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qr FROM Quer WHERE qr = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quer WHERE qr = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@)" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF)" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D-" Then '--Delete from Counter 9
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qc FROM Quec WHERE qc = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quec WHERE qc = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@-" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF-" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
Else If DelSrch = "@D+" Then '--Delete from Counter 10
Try
Dim delp As Map
Dim Resultp As String
delp.Initialize
delp = DBUtils.ExecuteMap(SQL, "SELECT qw FROM Quew WHERE qw = '"& searchDel.trim & "' ",Null)
Resultp = delp.GetValueAt(0)
Delay(250)
DBUtils.ExecuteMap(SQL, "DELETE FROM Quew WHERE qw = '"& searchDel.trim & "' ",Null)
astreams.Write("DEL@+" & searchDel.trim & Chr(13))
Catch
astreams.Write("NF+" & Resultp & searchDel.trim & Chr(13))
Log("Eror deleting")
End Try
End if
End if
End Sub
Last edited: