B4J Question B4J to B4A WebSockets question

techknight

Well-Known Member
Licensed User
Longtime User
I was looking and playing around with the various WebSocket examples for sending data and calling subroutines between a B4A client, and a B4J websocket server.

Thats awesome, but, here is the question:

What if I have multiple B4A clients connected to the B4J websocket server, How do I send messages to specific clients and not others??
 

Roycefer

Well-Known Member
Licensed User
Longtime User
You need to store the WebSockets in a global Map. Add a WebSocket to the Map in the _Connected event and remove it in the _Disconnected event.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I saw that example. But again its not clear to me how you can send messages to a specific websocket. Sure I can hold a websocket in a map, but then what?

Do I do map.send? what do I do?
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
I THINK I have it figured out. an ID is generated at the client and sent back over, and stored with the object. I keep forgetting to think 4th dimensionally, each person that connects over a websocket, creates a new temporary "copy" of PushB4A and its instance is stored in the map along with the unique ID and thats how it works.... as far as I can tell.

Next thing, is there a B4i client like the B4A client??

Edit: Found it. all I had to do was use the magical search field.
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Upvote 0
Top