NIO Article question..

Was re-reading the article by Adam Martin for the nth time and was hoping someone could clarify the following bullet point int he changes form io to nio section of the tetris example. Link:http://grexengine.com/sections/externalgames/articles/Adam%20Martin-Java%20NIO%20Networking%20for%20Games-3.html

…but we DO still need to maintain separate outgoing queues for each player

What would be best practive for doing the above?

The point was that although you no longer need a THREAD per client you still need to keep a DATA STRUCTURE per client - you cannot just naively say “ok now I’ve only got one thread and one message to send to everyone” (unless you broadcast) because each socket will send data at a different rate (different net connections) so will be a different distance through it’s own send buffer.

Typical approach is to use key.attach() to put a small data structure on the key which represents teh channel + selector for each client (each client has one channel, hence a unique key).

That DS usually is or contains a buffer of “data not yet sent” or “data read so far but not yet processed” if you have just got one selector per action (read, write, accept) - but if you share your selector amongst all, you need to actually have a DS like an array or better a class that has methods like get/setReadBuffer, get/setWriteBuffer.

gotcha and I am already doing that…cool! Now back to debugging! LOL