Hi,
I look at the demo (server)code of the websockets an I see the WebSocket_Connected method.
I assume that each concurrent clientconnection gets its own WebSocket instance server-side ?
When I receive a message from the client (Device_Message method in the example) it seems this method does not have a websocket as parameter. How do I know from which socket the request is comming from ?
I would need to have a link between a websocket and a user identification, and I guess this is only possible when the client sends a message to the server with the user identification as a parameter, the Device_Message method could then link the ID with the websocket instance...
I also noticed there is a TextMessage event on the WebSocket class: should I use this event ?
Thanks
Private Sub WebSocket_Connected (WebSocket1 As WebSocket)
ws = WebSocket1
timer1.Initialize("timer1", 1000)
timer1.Enabled = True
End Sub
Sub Timer1_Tick
ws.RunFunction("ServerTime", Array As Object(DateTime.Time(DateTime.Now)))
ws.Flush
End Sub
Sub Device_Message(Params As Map)
Log("Device message: " & Params.Get("message"))
End Sub
Private Sub WebSocket_Disconnected
timer1.Enabled = False
Log("disconnected")
End Sub