B4J Question Websocket server events

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I would like to ask you something about the server events and ws.flush statement.
I have the following code structure:
B4X:
Public Sub Some_Event(data As Map)
    If data.Get("var") = "0" then
       DoSQL1
    Else
       DoSQL2
    End if
End Sub
The Some_Event is a server event called from tablets.
The DoSQL subs, execute some updates or inserts into my database.
At the end of Some_Event, it's definitely not needed the ws.flush...
Is it needed at the end of DoSQLx?

Finally, what is the impact of having a ws.flush at the end of a server event called from devices?
May it causes memory leaks or something else?
I was accidentally having one case like this and I'm not sure if this caused a relatively big memory use from my web server, because I corrected this just yesterday.

Thank you in advance.
 

billzhan

Active Member
Licensed User
Longtime User
' https://b4x.com/android/forum/threads/webapp-chatroom-threads-sessions-and-server-events.39969/


Client(browser/phone) - data -> Server (Some_Event is called , it may/may not send data/function to client ) , ws.flush is not needed. This is not a server event.

Server event: initialized from server side (by timer or callsub from other threads) and has to send data/function to client. If ws.flush is not called, the data may not be sent to client immediately, this will not cause memory issue when data size is small.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…