Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  What would you suggest for an online game?  (Read 1015 times)
0 Members and 1 Guest are viewing this topic.
Offline CTucker1327
« Posted 2013-12-15 04:35:32 »

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.

Offline wessles

JGO Wizard


Medals: 64
Projects: 4
Exp: 3 years


Radirius Software Developer


« Reply #1 - Posted 2013-12-15 05:02:57 »

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.

Offline CTucker1327
« Reply #2 - Posted 2013-12-15 05:53:43 »

I wasn't expecting it to be made for games, just something to build on with plenty of tutorials.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CTucker1327
« Reply #3 - Posted 2013-12-15 06:07:11 »

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.
Online noblemaster

JGO Ninja


Medals: 20
Projects: 10


Age of Conquest makes your day!


« Reply #4 - Posted 2013-12-15 06:34:04 »

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.
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.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
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();  
}

Offline CTucker1327
« Reply #5 - Posted 2013-12-15 06:36:59 »

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.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (32 views)
2014-07-18 06:55:21

Zero Volt (28 views)
2014-07-17 23:47:54

danieldean (24 views)
2014-07-17 23:41:23

MustardPeter (25 views)
2014-07-16 23:30:00

Cero (40 views)
2014-07-16 00:42:17

Riven (42 views)
2014-07-14 18:02:53

OpenGLShaders (29 views)
2014-07-14 16:23:47

Riven (29 views)
2014-07-14 11:51:35

quew8 (26 views)
2014-07-13 13:57:52

SHC (63 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!