Hello Everyone,
I'm developping a server application that use websocket, where typically I store each object of the websoket class in a map initialized as a ThreadSafeMap.
When I need to call a client method I iterate through the map objects and I call the sub of the websocket class that call the ws.RunFunction method
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Here is my question: for a better performance is it better to call CallSub2(c,"send",payload) or CallSubDelayed2(c,"send",payload) assuming an high number of clients connected on different type of internet connections (lan,mobile,etc..) with different speeds and latencies ?
Thanks for the attention
			
			I'm developping a server application that use websocket, where typically I store each object of the websoket class in a map initialized as a ThreadSafeMap.
When I need to call a client method I iterate through the map objects and I call the sub of the websocket class that call the ws.RunFunction method
			
				B4X:
			
		
		
		' in the Main
Sub Process_Globals
    Public mapConnection As Map
    Public srv As Server
    Public tmrSeconds As Timer
End Sub
Sub AppStart (Args() As String)
    srv.Initialize("objServer")
    srv.AddWebSocket("/ws","WebsocketConnection")
    srv.Port = 51042
    srv.Start
    mapConnection = srv.CreateThreadSafeMap
    tmrSeconds.Initialize("tmrSeconds",1000)
    tmrSeconds.Enabled = True
    StartMessageLoop
End Sub
Sub tmrSecondi_Tick
   dim payload as String
   tmrSeconds.Enabled = False
   payload = "somthing to trasmit retrived by a function";
   For Each c As WebsocketConnection In mapConnection.Values
       CallSub2(c,"send",payload)
   next
   tmrSeconds.Enabled = True
End Sub
' in the WebsocketConnection class '
Sub Class_Globals
    Private ws As WebSocket
End Sub
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
    ws = WebSocket1
    Main.mapConnection.Put(ws.UpgradeRequest.GetParameter("client_uuid"),Me)
End Sub
Public Sub send(payload As String)
    ws.RunFunction("recive_payload",Array As String(payload))
    ws.Flush
End SubHere is my question: for a better performance is it better to call CallSub2(c,"send",payload) or CallSubDelayed2(c,"send",payload) assuming an high number of clients connected on different type of internet connections (lan,mobile,etc..) with different speeds and latencies ?
Thanks for the attention
 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		