Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
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  
  RMI or Sockets for networked game  (Read 3226 times)
0 Members and 1 Guest are viewing this topic.
Offline zngga
« Posted 2012-07-02 01:32:30 »

I am looking into possible solutions to a networked game i am working on. My first thought was sockets with message objects, but the giant strings of if statements that are necessary for this approach is putting me off. So I was looking at RMI, which seems to let you call methods on a remote machine as if they were declared on you local machine. (correct me if I am wrong) Which, on the surface, looks awesome... but there has to be a reason it isn't widely used for games. So what do you think, is RMI feasible for networked games, and if so do you care to give me a quick run through on how it works?

My code never has bugs... it just develops unexpected features!
Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #1 - Posted 2012-07-02 02:48:06 »

http://code.google.com/p/kryonet/
Smiley

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2012-07-02 03:44:32 »

Java's RMI should not be used for realtime I/O. It has many design flaws, and the only advantage of it is that it's shipped with the JRE. If anything, avoid it and use (something like) Kryonet.

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 65K
« Reply #3 - Posted 2012-07-02 06:08:02 »

My first thought was sockets with message objects, but the giant strings of if statements that are necessary for this approach is putting me off.
Just create a map of message types and handlers, look up the registered handler for each incoming message and call it.

Offline Nate

JGO Kernel


Medals: 145
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #4 - Posted 2012-07-02 06:53:49 »

Java's RMI should not be used for realtime I/O. It has many design flaws, and the only advantage of it is that it's shipped with the JRE. If anything, avoid it and use (something like) Kryonet.
KryoNet has a simple RMI system. It was written mostly just to see how simple it could be done (~441 lines using the CLOC tool). In practice, I still wouldn't bother with RMI as having some method calls go over the network is just too much magic for me. It also has some very minor overhead. The alternative really isn't a big deal, which is to explicitly send and receive messages (objects with KryoNet).

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #5 - Posted 2012-07-02 07:41:20 »

The biggest problem of RMI is that every 'remote call' will block until it received a response from the server: the return value or a remote exception. This means that the maximum messages / second is not determined by your bandwidth, but by the latency of the network.

The second biggest problem of RMI is the distributed garbage collector. RMI will cause full GC's every once in a while, likely to cause hickups in your game.

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

Junior Newbie





« Reply #6 - Posted 2012-07-02 09:21:53 »

The second biggest problem of RMI is the distributed garbage collector. RMI will cause full GC's every once in a while, likely to cause hickups in your game.

That's interesting, does that apply to the server and/or client side?

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #7 - Posted 2012-07-02 09:31:27 »

both

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

Junior Member





« Reply #8 - Posted 2012-07-02 15:19:14 »

In addition to the quite excellent reasons already enumerated, by using RMI you pretty much limit yourself to a Java client for your game which may or may not be a problem for you.  I generally avoid using RMI at all costs for any purpose Smiley
Offline zngga
« Reply #9 - Posted 2012-07-02 22:16:54 »

Well thank you all for the insight. I had never heard of RMI before now, and I knew there had to be a reason why. You have all saved me the trouble of finding out myself! Smiley I really like kryonet, I was going over the java docs and it is brilliant! I will probably use it in every game I make from now on!

My code never has bugs... it just develops unexpected features!
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.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (59 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!