B4J Question B4J web socket server, run function on specific device

Mostez

Well-Known Member
Licensed User
Longtime User
I have two ESP32 web socket clients connected to B4J web socket server, for example device 1 and device 2, I want to run function on specific device say device1 to set device name or any other configs, like this scenario:
the server services html 'Setup' page http://127.0.0.1:51042/setup
on setup page;
the user enters device identification key (IP address or any available identification method) to select desired device.
user enters new device name and then click submit button
the server then starts WebSocket.RunFunction

I don't know if that scenario is possible or not, is there any other method to implement this config tool?
how to identify device which user want to configure?

TIA
 

LucaMs

Expert
Licensed User
Longtime User
I have two ESP32 web socket clients
I don't know about ESP32, but using your own websocket server you should create an handler class instance for each new connection, which will have its own websocket.

Store those instances (in a Map; it is recommended to use something like: mapClients = YourServerVar.CreateThreadSafeMap to create it) and send message to one you want.

You can find on this site many examples created by Erel.
 
Upvote 1

Mostez

Well-Known Member
Licensed User
Longtime User
After one month of working on this project it's almost done as planned for.
Now I've B4J server, device monitoring and config web pages, B4A config tool, and B4R ESP32 software.
Thanks @LucaMs for your guiding answer, Thanks @Erel for providing such great programming IDE's with this high level of integration.
 
Upvote 0
Top