B4J Question [JServer | Websocket Server] send multiple data through frames

Waldemar Lima

Well-Known Member
Licensed User
Hello everyone,
is it safe and reliable for me to send multiple server information to the client this way?

Client :

B4X:
' Sending Request from Client to WebSocket Server
    Dim data As Map
    data.Initialize
    data.Put("username", "")
    wsh2.SendEventToServer("Device_Teste",data)
    data.Clear

' Sub to receive Msg from Websocket Server
Sub wsh_Server_Teste(Params As List)

    Log("Ingressado Autenticado !")
    Dim Answer As String = Params.Get(0)
   
    Log(Answer)
   
End Sub


Server Websocket Sub :

B4X:
'Sub to Send data to Client 
Sub Device_Teste(Params As Map)
    Log("Teste Call")
  
    For i = 1 To 500
        ws.RunFunction("Server_Teste", Array As Object(i))
        ws.Flush
    Next
  
End Sub
 

Waldemar Lima

Well-Known Member
Licensed User
I'm sure this is fine, but:

Since you know all 500 frames, why don't you just create an array and send them all at once?

If you intend to include password verification, I would always suggest hashing and verifying on the server end. https://www.b4x.com/android/forum/threads/bcrypt-create-salted-hashes-compatible-with-php.110180/

my fear is that the information that would be sent frame by frame to the client would exceed 65565 bytes of packet size. So from my point of view, sending one by one would not have memory overflow, right?
 
Upvote 0

lucasheer

Active Member
Licensed User
Longtime User
my fear is that the information that would be sent frame by frame to the client would exceed 65565 bytes of packet size. So from my point of view, sending one by one would not have memory overflow, right?

I don't think there is a limit to the packet size, but you can send a bitmap or a generated array to test this.

You should be good :)
 
Upvote 0
Top