i am trying to handle multiable in Asyncstream by doing the following
in the newdata first i receive command1 and parse it then send command2 and wait for response then
if the paramnum equals command2 then parse it but when command2 arrived and paramnum(0) equals command2 the log show old data from paramnum(1) not the one that expected is what i am doing is correct ?
B4X:
Public Sub NewData (data() As Byte)
Dim msg As String
msg = BytesToString(data, 0, data.Length, "UTF-8")
msg = msg.Trim
Dim param As String = msg
Dim paramnum() As String = Regex.Split("\&", param)
If paramnum(0) = "Command1" Then
For i = 1 To paramnum.Length-1
If paramnum(i) <> "" Then
log(paramnum(i))
End If
Sleep(0)
Next
If connected = True Then
SendData(Bconv.StringToBytes("1"&"Command2~", "UTF-8"))
End If
End If
If paramnum(0) = "Command2" Then
Log(paramnum(1))
End If
End Sub
in the newdata first i receive command1 and parse it then send command2 and wait for response then
if the paramnum equals command2 then parse it but when command2 arrived and paramnum(0) equals command2 the log show old data from paramnum(1) not the one that expected is what i am doing is correct ?