Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 is the best fitted networking tool in Java for a multiplayer FPS?  (Read 5991 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej
« Posted 2008-05-08 16:14:08 »

Hi!

When I began thinking about an online mode in my FPS, I thought only about RMI but problems of latency may discourage me to use it (if you compare with RPC for example). I'm looking for a better solution. I wanted to put the model part on the server and the controllers and the the views on the clients of course. I'm looking at MINA, the Network Game Engine of Riven and CommanderKeith, UDP and TCP/IP sockets, project darkstar... I don't know what is the best fitted solution for my project. Can you give me your point of view about this?

Offline CommanderKeith
« Reply #1 - Posted 2008-05-08 16:55:25 »

That's a very interesting question!

For an FPS where the landscape is static and the player controls just one character and not vehicles or anything, probably the best way to do it is a custom solution where you send raw byte arrays over TCP which have info like:

world timeStamp
player position
player direction

and these can be sent whenever direction changes, as well as just for an update say 5 or 10 times a second. You'd also send a byte array with info when a player changes state such as picking up a gun.

But such custom methods are pretty hard to do in practice, since without sending the whole game world from the server to all clients, the clients inevitably get out of sync. This can happen just from floating point error. It's also extremely hard to code a completely deterministic world where clients and server do exactly the same thing - AI, randomness, etc become pretty difficult. But, Kev Glass does it well in his games - MiniMotox uses a clever system similarish to what I described above (I think!)- but besides the racing trucks, the world is static.

The demo game I posted up (http://www.java-gaming.org/forums/index.php?topic=18019.msg141395#msg141395) has got a couple of neat features which allow you to forget about all of the sync'ing and byte-array construction of data. The whole world can be serialized and sent to all clients, and the world can be re-wound so the server can go back in time to apply a lagged client event. While the sample game worked pretty well (it ran for months on Riven's internet server without any problems), the code is undocumented and it is not a pluggable frame work at all - you'll have to start with the demo game and carefully graft your own code on which wouldn't be the funnest thing. One day I'll try and fix it up, for now I just want to use it.

Good luck with your project. Incorporating network play is pretty hard so don't be discouraged if you find you need to completely re-design the way your game currently works.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2008-05-08 18:38:34 »

Quote
"Network Game Engine of Riven and CommanderKeith"

There is not such thing (yet).

I'm in the process of wrapping NIO into something 'usable for everybody', but it's far from done.

AFAIK, CommanderKeith uses MINA, and wraps it a bit to suit his needs. (He has lots of needs! Wink)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2008-05-08 20:39:57 »

That's a very interesting question!

For an FPS where the landscape is static and the player controls just one character and not vehicles or anything, probably the best way to do it is a custom solution where you send raw byte arrays over TCP which have info like:

world timeStamp
player position
player direction

and these can be sent whenever direction changes, as well as just for an update say 5 or 10 times a second. You'd also send a byte array with info when a player changes state such as picking up a gun.

But such custom methods are pretty hard to do in practice, since without sending the whole game world from the server to all clients, the clients inevitably get out of sync. This can happen just from floating point error. It's also extremely hard to code a completely deterministic world where clients and server do exactly the same thing - AI, randomness, etc become pretty difficult. But, Kev Glass does it well in his games - MiniMotox uses a clever system similarish to what I described above (I think!)- but besides the racing trucks, the world is static.

The demo game I posted up (http://www.java-gaming.org/forums/index.php?topic=18019.msg141395#msg141395) has got a couple of neat features which allow you to forget about all of the sync'ing and byte-array construction of data. The whole world can be serialized and sent to all clients, and the world can be re-wound so the server can go back in time to apply a lagged client event. While the sample game worked pretty well (it ran for months on Riven's internet server without any problems), the code is undocumented and it is not a pluggable frame work at all - you'll have to start with the demo game and carefully graft your own code on which wouldn't be the funnest thing. One day I'll try and fix it up, for now I just want to use it.

Good luck with your project. Incorporating network play is pretty hard so don't be discouraged if you find you need to completely re-design the way your game currently works.

TUER is planned to become far from static but as the model part is on the server, it is easy to keep synced for a client, it only gets the required data, not the whole world, only the data contained in the visible cells in the view point of the player. In the worst case, as the data often change and lots of them won't be proxied, if the client gets temporarily out of sync, it is not a problem as it will get the right data later when the network is alright anew, only one version of the world is available on the server and shared. I won't try to send only the differences between the old and the new world as it might cause deeper problems when the client is out of sync. As I wanted to use RMI, I tried to minimize the amount of data sent between the server and its clients, it will be useful whatever the solution I choose. I will have a look to what you did. What do you think about Project Darkstar?

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2008-05-08 20:57:06 »

The method Quake 3 uses is very elegent and robust, there is a good write up on it by Brian Hook:

http://trac.bookofhook.com/bookofhook/trac.cgi/wiki/Quake3Networking

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline gouessej
« Reply #5 - Posted 2008-05-09 10:13:19 »

Does someone know JRemoting?

Offline tom
« Reply #6 - Posted 2008-05-09 14:23:06 »

You might have a look at JGN (JavaGameNetworking) to do the dirtywork. You might also look at the monkey engine forum where the author posts frequently.


Offline gouessej
« Reply #7 - Posted 2008-05-09 15:36:18 »

You might have a look at JGN (JavaGameNetworking) to do the dirtywork. You might also look at the monkey engine forum where the author posts frequently.
Ok I know it (http://javagn.org/wiki) but I don't use JME. Can I use it for my own engine??

Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2008-05-09 15:41:26 »

JGN is engine agnostic.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline gouessej
« Reply #9 - Posted 2008-05-10 09:42:05 »

I have looked in the doc of JGN, I don't know where to start. Where can I find a very very simple example to start? A sort of "hello world" with JGN?

Is it possible to use JGN like RMI or is it a different approach?

Is it better to regroup the data that have to be sent when using JGN?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline CommanderKeith
« Reply #10 - Posted 2008-05-10 10:15:20 »

There's a server-client chat program in the examples/tests somewhere which shows how it works.

Sunsett (Matt Hicks) will be glad to tell you what JGN is about, he's friendly and is always available on the JGN forums (http://www.captiveimagination.com/forum/index.php?board=4.0).

I've used JGN in my network framework instead of MINA and they both worked very well (I'm currently using MINA since it's rock-solid stable and seems to do pretty fancy thread-pooling which seems cool). Neither are like RMI however - RMI is completely different and you don't want to use it. JGN and MINA are primarily for sending and receiving byte arrays through either TCP or UDP. Both try to pretend they send objects by disguising the API with calls like send(object), but they're really just for sending byte array data.

JGN has some other features as I understand which might be handy (like code that can find out the time difference between the server and client clocks).

Maybe what you should think about is how you want to take lag into account in your game, and how you are going to turn your game objects into byte arrays, and then turn those byte arrays back into objects, because those apsects will be the most difficult problems.




Offline sunsett

Senior Member




ribbit!


« Reply #11 - Posted 2008-05-10 14:44:42 »

Sorry for taking so long to see this.  Was at JavaOne and had a pretty busy week. Smiley

The wiki is somewhat limited in what information is available there as it's almost entirely community driven.  However, as CommanderKeith explained there are tons of examples in the "test" package in the JGN source code.  I would recommend checking it out from SVN and giving it a shot.  Though CommanderKeith is correct on one hand that it is very different from RMI, there is actually functionality within JGN if you want to create something similar to RMI.  It's called RemoteObject.  Similar to RMI you create an interface and implementation.  The implementation gets registered on the machine you want to do the work and the interface gets passed to the RemoteObjectManager on the remote machine.  This will give you back a proxy instance of the object and when you invoke methods on the instance they will be remotely invoked and give you the return value locally.

See this:

http://svn.javagn.org/core/trunk/src/com/captiveimagination/jgn/test/ro/TestRemoteObject.java

Here is an extremely simple example using JGN:

http://svn.javagn.org/core/trunk/src/com/captiveimagination/jgn/test/basic/TestMessageServer.java

There is a ton of other functionality in JGN and you can even just browse the SVN repository if you want to see that before you actually check it out.
Offline gouessej
« Reply #12 - Posted 2008-05-10 23:27:12 »

Ok, "RemoteObject" is a fine name as when I read this, I thought about something similar with "Remote" in RMI. For the deployment through Java Webstart, do you think that I should sign the JAR of JGN by myself or is it already done?

As a first step, I will clean my source code in order to strictly respect MVC and then I will begin handling networking. I don't want to rewrite all my game to add a multiplayer mode, I want to modify only the controllers, nothing else.

Is JGN stable? Some people on the web criticized it, they said it is developed only by one man. I hope this API won't be forgiven.

Offline sunsett

Senior Member




ribbit!


« Reply #13 - Posted 2008-05-10 23:50:45 »

No, the JAR is not signed so you'll need to do that yourself.  For all of my projects I create my own certificates anyway...do you see a benefit of JGN having its own?

Well, it is primarily developed by one person...me.  However, there are other contributors to the project, they primarily just do updates as needed while they are developing their own games.  Also, as others have stated, I do pretty well to keep up with people in the forums and I welcome the possibility of adding additional developers after they've proved their competence as a developer and have spent some time with JGN.

If you're looking to synchronize positional information of objects in your game you should take a look at the synchronization system.  It can be easily customized to work with any game engine (2D, 3D, Physics, etc.). Out of the box it supports GTGE, jME, jME-Physics, and Swing but it's maybe ten lines of code to writing your own.
Offline gouessej
« Reply #14 - Posted 2008-05-11 08:28:27 »

No, the JAR is not signed so you'll need to do that yourself.  For all of my projects I create my own certificates anyway...do you see a benefit of JGN having its own?
If you signed and you certified your JAR for JGN, it might be better. I will use the same certificate for my own JAR and this one so that the user won't have to confirm once more...
Well, it is primarily developed by one person...me.  However, there are other contributors to the project, they primarily just do updates as needed while they are developing their own games.  Also, as others have stated, I do pretty well to keep up with people in the forums and I welcome the possibility of adding additional developers after they've proved their competence as a developer and have spent some time with JGN.
Ok you reassure me.
If you're looking to synchronize positional information of objects in your game you should take a look at the synchronization system.  It can be easily customized to work with any game engine (2D, 3D, Physics, etc.). Out of the box it supports GTGE, jME, jME-Physics, and Swing but it's maybe ten lines of code to writing your own.
I hope you're right as (no way!) I don't want to rewrite all to fit into a networking API. Maybe it is too early to choose a networking solution. Jeffrey Kesselman says that Project Darkstar may fit into my needs. Therefore, I will compare the both solutions.

Offline sunsett

Senior Member




ribbit!


« Reply #15 - Posted 2008-05-11 13:50:48 »

If you signed and you certified your JAR for JGN, it might be better. I will use the same certificate for my own JAR and this one so that the user won't have to confirm once more...Ok you reassure me.I hope you're right as (no way!) I don't want to rewrite all to fit into a networking API. Maybe it is too early to choose a networking solution. Jeffrey Kesselman says that Project Darkstar may fit into my needs. Therefore, I will compare the both solutions.

I wouldn't think it a good idea to make my certificate available for anyone to use as that would really violate the purpose of the certificate.  I mean, people decide they trust my certificate for JGN and accept it.  If anyone could use it they could sign their application which the user may not trust, but it then is automatically trusted.  Also, other APIs like jME come with their own certificate as well...it just seems less complicate to let everyone sign their own JARs.

You can see an example usage of synchronization (using jME graphical synchronizer) using the jME FlagRush tutorial here:

http://svn.javagn.org/synchronization/jme-networking/trunk/src/com/captiveimagination/jmenet/flagrush/

Though the majority of code there is specific to jME if you look at the networking code you'll see how few lines of code it takes to set it up.
Offline gouessej
« Reply #16 - Posted 2008-09-09 20:06:48 »

For the moment, I'm going to use RMI even though I fear it will be slow. If JGN is abandoned, nobody will help me using it...

Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #17 - Posted 2008-09-09 20:11:57 »

RMI is horrible for a FPS.

Don't waste time on it.

It also has this distributed GC, which WILL periodically pause your game very noticably.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline sunsett

Senior Member




ribbit!


« Reply #18 - Posted 2008-09-09 20:51:44 »

For the moment, I'm going to use RMI even though I fear it will be slow. If JGN is abandoned, nobody will help me using it...

What makes you think JGN is abandoned?  Many people use it actively...and since I'm the creator and sustainer of the project, I say it is far from dead. Wink
Offline gouessej
« Reply #19 - Posted 2008-09-09 21:52:37 »

RMI is horrible for a FPS.

Don't waste time on it.

It also has this distributed GC, which WILL periodically pause your game very noticably.
At work, we succeeded in reducing the length of this pause to something "acceptable".

What makes you think JGN is abandoned?  Many people use it actively...and since I'm the creator and sustainer of the project, I say it is far from dead. Wink
I have seen only 3 games using it on your website.

I will invest only a very little time to make a blueprint using RMI. If it is really horrible even though I make some efforts to limit the number of RMI calls, then I will look at JGN.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 744
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #20 - Posted 2008-09-09 22:48:57 »

At work, we succeeded in reducing the length of this pause to something "acceptable".


The problem grows with a growing heap. So a 'benchmark' might not be the best testcase.

If you tested in real world usecases, and thought it was acceptable (which I find surprising) you're OK, ofcourse

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline gouessej
« Reply #21 - Posted 2008-09-09 23:01:55 »


The problem grows with a growing heap. So a 'benchmark' might not be the best testcase.

If you tested in real world usecases, and thought it was acceptable (which I find surprising) you're OK, ofcourse
The problem is that this application doesn't need real-time performance unlike my FPS. If I decide not to implement a small piece of the multiplayer mode now, it will be harder when I will have to do it. The much time I wait, the more efforts I will need to do it.

To reduce this pause, you can choose a low-pause algorithm for garbage collection, you can fix a maximum length for pauses and all objects in the model part of the application (MVC) have to implement Serializable and Remote to prevent the JVM from copying the remote objects instead of using a stub. You can use a table that tells when something has changed on the server and the clients can look at this (synchonized) table to check if it is really useful to get the data from the server rather than using the data already in the proxy. The model part has to be thread-safe as several clients can get data from it. However, the biggest problem comes from the latency.

Offline sunsett

Senior Member




ribbit!


« Reply #22 - Posted 2008-09-10 01:33:46 »

I agree with Riven, RMI is most definitely *not* designed for real-time.

This topic has actually been debated a few times before.  I'll refer you to a previous post I made:

http://www.java-gaming.org/topics/anyone-ever-tested-rmi-for-a-game/17309/msg/137256/view.html#msg137256

Also, as far as games that use JGN, there are many more, but my lack of attention to mentioning them and letting developers know that page even exists is entirely my fault. Smiley
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.

Riven (11 views)
2014-07-29 18:09:19

Riven (8 views)
2014-07-29 18:08:52

Dwinin (9 views)
2014-07-29 10:59:34

E.R. Fleming (25 views)
2014-07-29 03:07:13

E.R. Fleming (10 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (27 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21
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!