What would you suggest for an online game?

I’m wanting to make my platformer multiplayer, and while I know how to do some of the more advanced things, it’s the “simple things” such as a packet system that I don’t really understand.

I understand how to make an authoritive server, how it works, etc, but I’m not so great at how to transfer the data back and forth between the server/client information on what it’s for.

I know that I can do things like, send everything in a string data, using “[packetname]” as a tag, then decode it on the server-side, but there has got to be a better way to do things, so I guess I’ll go ahead and ask.

I’ve been told to use DatagramServer with DatagramPackets, but I’ve read that they are extremely unreliable, is this true?

Would I be better off using IO, NIO, Netty, Mina, Etc?

I’m still learning and this is going to be my first multiplayer project (That I’ve wrriten the core of the server for) and I’m just not too sure how where to begin. I’ve worked on plenty of projects where the server was already completed and I was just adding things like server-sided collision/logic checking, but this is my first “From scratch” project.

I haven’t had the chance to use it, but a quick google brought up an IO framework for ‘fast, low-latency connection,’ TCP, and great for games. Check it out: Netty IO. Keep in mind it is not made for games, but you can build on top of it.

I wasn’t expecting it to be made for games, just something to build on with plenty of tutorials.

Netty is good, and I was thinking about using it. I have used it on my Runescape Emulators before (Sadly, this is where I started), but I never actually wrote the structure, however I’ve done stress test comparisons between Netty/Mina/IO and Netty definately won.

If you are planning to setup a standalone server you might want to look into WebSockets as well. I have used Mina, Jetty, etc. before so there all fine in my opinion. The biggest problem isn’t how you send the data but enabling people to connect to the server. If you have a standalone server (somewhere in the internet) it’s generally not a problem to connect to the server (as long as you use port 80 - could be web sockets), but someone hosting a server at home is always asking for trouble (the player will need to enable port-forwarding/tunneling etc.). Also, for hosting at home, you might want to setup a match-making server. No one is going to play your game unless they have a server to connect to.

[quote]I know that I can do things like, send everything in a string data, using “[packetname]” as a tag, then decode it on the server-side, but there has got to be a better way to do things, so I guess I’ll go ahead and ask.
[/quote]
I guess that’s general idea: you send the packet type (could be an integer/byte too to reduce size of data you send) then process & return the data.

I suggest you abstract the client-server communication so you can switch out the underlying networking system (be it NIO, Netty, Jetty, Mina…) etc. easy. Something like a web socket type interface might work nicely given you are looking for packet-type communication (same interface for both client and server). Although NIO, Mina etc. are stream-based connections, you can easily implement them so the behave like a web socket as below.

public interface WebSocket {

  /** The WebSocket session/connection. */
  public static interface Session {

    /**
     * Sends a text message.
     * 
     * @param data  The message.
     * @throws Exception If something goes wrong.
     */
    public void sendMessage(String data) throws Exception;
        
    /**
     * Closes a connection.
     */
    public void close();
  }

  // -------------------------------------------------------------------------------------------------------------------
  
  /**
   * Called when a new websocket connection is accepted.
   * 
   * @param session  The session.
   */
  public void onOpen(Session session);
  
  /**
   * Called with a complete text message when all fragments have been received.
   * 
   * @param data The message.
   */
  public void onMessage(String data);
  
  /**
   * If there was an error.
   * 
   * @param e  The error encountered.
   */
  public void onError(Exception e);
  
  /**
   * Called when an established websocket connection closes.
   */
  public void onClose();  
}

It’s going to be server based, and I already have port-forwarding etc set up for multiplayer testing, I understand that peple will want a “Server” to connect to and that’s not a problem, I have a friend that runs one of the datacenters in houston.

EDIT: I’m not good good with “Abstracting” things, as I haven’t really ventured into that part of programminh yet.
EDIT2: Stream based is pref what I’m looking for anyway.