' 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 Sub