Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How? NIO: handshake, auth, lobby, rooms....

  1. #1
    Junior Member
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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?


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,282
    My Mood
    Happy
    Thanks
    70
    Thanked 158 Times in 154 Posts

    Default 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

  3. The Following User Says Thank You to Json For This Useful Post:

    Hippy (March 6th, 2011)