So, for sending to individual streams we have to reference the connected netStream we want to send to in some way like this:
sendStream.peerStreams[0].send("MyFunction",param1,param2);
and I have to determine which peer I’m sending to by their ID such as “peerID1234”
I know that you can check the peerID of the stream by doing:
sendStream.peerStreams[0]["farID"]
how can I make my send stream function know to use the array index where the peerID is?
so basically it could be like:
sendStream.peerStreams[where peerStreams[]["farID"] == peerID].send("MyFunction",param1,param2);
Sounds like you’ll have to loop through the
peerStreamsarray to find the object that has the rightfarIDproperty value. Basically you are searching through the array for an item with a specific property value. There is no built-in functionality for this. But you can do it with a simple loop. Something like this:Note that I don’t know what the data type is for the
peerStreamsobject so I just typed it asObjectin my example.There’s some other approaches mentioned here but they are just different styles of doing the same thing.