Hello,
I have a (potentially) infinite list of Integers, one for each person current connected to my socket server. These numbers a short, starting at 0,1,2...etc
The idea are these a temporary unique IDs that stay with a user for their duration on my server:
When a user joins they are assigned the first available number.
When a user leaves, their number is recycled and waits for assignment to someone else.
My code allows for these numbers to be as long as I like but I want to keep them short to conserve the number of bytes sent to each client from my server.
I need to reuse these numbers somehow. I have a list of clients in each room but no centralised list, even if I did I would need to run through every client that was on the server (could be many!) so I need a better way of finding the first available number.
I had an idea of using something like:
But it has problem in that it limits me to 100000 clients at any one time! I may have more but I certainly will have fewer in this case the array wastes memory.Code:boolean ids[]= = new boolean[100000];
I'm just posting here because I'm sure this has already been solved but I had trouble finding any answers with google. Thanks for reading,
Dan

