Android Question Connecting to Multiple Websocket server

rhydo

Member
Licensed User
Longtime User
Using B4A , i would like to connect multiple web servers in a local area network through web-socket. I had given same EVENT name for all instances of web-socket and all are getting connected to different IP addresses as expected and common events are getting triggered. Since there is no TAG property for web-socket , i cannot use the SENDER option in the event functions for identifying web-socket those who triggered the event . If anybody can suggest a solution , it will be really help full.
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
If you are maintaining an array of the sockets as you create them, you can iterate through that array and check if Sender = Socket(index) to see which one is firing the event.
 
Upvote 0

rhydo

Member
Licensed User
Longtime User
Another option, which is usually better in the longer term, is to add a class that handles a single connection and then create multiple instances of this class. One for each connection.
Thank you for your reply .
"which is usually better in the longer term" , you mean continuing with code having the array of web-sockets may face difficulties in future b4x updates ? or Android updates ?
 
Upvote 0
Top