SergeNova
Member
Hello, I searched the forum for how to use a B4A application as a WebSocket server but I couldn't find anything. Is this really possible? If yes, how? or a link to the example will be really helpful.
Somewhere on the forum I found a module which pretends to be a B4A websocket server, if it is the case I do not see how to create a URL (Or Address) of the server, I may not have an idea but if anyone knows how to do it please help me here is the code has question:
Thank you Best regards
Somewhere on the forum I found a module which pretends to be a B4A websocket server, if it is the case I do not see how to create a URL (Or Address) of the server, I may not have an idea but if anyone knows how to do it please help me here is the code has question:
B4X:
'WebSocket class
Sub Class_Globals
Private ws As WebSocket
Private timer1 As Timer
End Sub
Public Sub Initialize
End Sub
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
Last edited: