How? NIO: handshake, auth, lobby, rooms....
Hello everyone!
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:
xxxx://code.google.com/p/quantum-game/source/browse/?r=13#svn%2Ftrunk%2Fsrc%2Fmain%2Fjava%2Fquantum%2F net
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....
Hello noncom,
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.
// Json