i am trying to send the connected client list in the server using map and json as following
i excpected to have a lines of record as example
{"cname":"user1","cEmail":"user1email"}
{"cname":"user2","cEmail":"user2email"}
{"cname":"user3","cEmail":"user3email"}
{"cname":"user4","cEmail":"user4email"}
etc....
its sends only one record even if there 1000 clients connected what i am doing wrong ?
B4X:
Public Sub SendClientList(Meclient As TcClient)
If clients.Size > 0 Then
Dim muser As Map
Dim jsgen As JSONGenerator
muser.Initialize
For i = clients.Size -1 To 0 Step -1
Dim aClient As TcClient
aClient = clients.Get(i)
If (aClient.iamconnected = 1) Then
muser.Put("cname", aClient.username)
muser.Put("cEmail", aClient.Email)
End If
Next
jsgen.Initialize(muser)
Dim clientsListstring As String
clientsListstring = jsgen.ToString
Meclient.SendData(clientsListstring)
End If
End Sub
i excpected to have a lines of record as example
{"cname":"user1","cEmail":"user1email"}
{"cname":"user2","cEmail":"user2email"}
{"cname":"user3","cEmail":"user3email"}
{"cname":"user4","cEmail":"user4email"}
etc....
its sends only one record even if there 1000 clients connected what i am doing wrong ?
Last edited: