How? NIO: handshake, auth, lobby, rooms....
I have made a simple computer game and now I want to make it multiplayer. Because the game is strategic and has a persistent world, I would like to make the network code based on NIO rather than on blocking sockets (so that it could hold many hundreds of clients and, as a side effect, I would gain a good knowledge of nio). I know there is a huge amount of work for me to do but it is ok. The problem that I have is that I cannot figure out how to write the NIO code properly...
To give an idea of what I want it to look like, here is a code of a server that I took as an example:
It has the Login, Lobby and Game sections. However, it is written using the blocking sockets. So I have read much about NIO and written my server and client as in NIO examples (just plain boring "hello"-"hello" thing). But still I can't understand how to create the separate handshake, authorization, lobby and game rooms? From what I understand, there should be ONE selector for the server, which should manage all connections? What keys and interest ops should be used and how?
Could please anyone describe, how to write a server that has all these features? Which way to go?
Re: How? NIO: handshake, auth, lobby, rooms....
Maybe you should look into an existing framework to solve the network wrapping for you such as kryonet - Project Hosting on Google Code or Apache MINA - Welcome to Apache MINA Project!
There are tons out there.