Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
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  
  Two communication channels?  (Read 2952 times)
0 Members and 1 Guest are viewing this topic.
Offline Astrosmurf

Junior Newbie




Java makes your spirit soar!


« Posted 2006-10-24 06:50:59 »

Hi!

I would be glad to have some feedback on my idea. I'm currently in the middle of implementing networking in my first networked Java game (http://sourceforge.net/projects/motopain).
I have implemented two communication channels, one reliable (TCP) and one unreliable (UDP). UDP are used for position updates and TCP are used for messages such as collisions, inhabitants removed or added in the game world and other stuff that affects the game state more severely.
I'm pretty confident that I'm not the first to have these thoughts, so if any of you have tried something similar I would appreciate if you would share some of  your experiences.
My main concern if is there is a cost involved with having a connection open (I set keepAlive to "true") to the server?

Regards Anders

If a problem has a solution, why worry? If a problem does not have a solution, why worry?
Offline sunsett

Senior Member




ribbit!


« Reply #1 - Posted 2006-10-27 19:02:36 »

That's actually pretty typical I believe.  It's the way I do all my game development. JGN has built-in functionality to provide dual connections per client to the server (or P2P) and the system manages what stream should be utilized. I think the only place you'll really run into performance ramifications is if you are not using the NIO functionality in Java.

There are people here much more knowledgable than myself in here, so I'll wait to see if I'm corrected. Wink
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #2 - Posted 2006-10-28 12:55:16 »

from experience, collision on the client side is just a bad bad idea that going to bite you...What if client1 says he shot client2, but client2 says that client1 didn't? What are you going to do then ?

Just do collisions server side...

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mr_Light

Senior Member


Medals: 1


shiny.


« Reply #3 - Posted 2006-10-28 15:18:14 »

optimistic checking? (as stolen from optimistic locking.) only wenn clients disagree should the server check whois right? kinda offtopic.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #4 - Posted 2006-10-28 22:31:52 »

"only when they disagree"...thats sorta like 99% of the time in fast action paced games...

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline Astrosmurf

Junior Newbie




Java makes your spirit soar!


« Reply #5 - Posted 2006-10-30 08:18:54 »

"only when they disagree"...thats sorta like 99% of the time in fast action paced games...


Yes...
The problem is that I do not have a server who holds a state, the server only keeps track of participants in the game and relays messages.
My idea of collison detection is to let the client who has the object (car) locally decide if there is a collison or not.
Somehow I will try to make it beleivable in the gameplay, one idea I have is to make the bounding shape  used for collision detection somewhat smaller than the sprite, thus a "near hit" will be more beleivable as a hit for the part who did not perceive a collision.
This approach means that each client is authorative over its local objects and acts a server for them, whereas it will not perform collison detection for objects residing on other nodes.



If a problem has a solution, why worry? If a problem does not have a solution, why worry?
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #6 - Posted 2006-10-30 14:02:14 »

Sure, go ahead - Write the game, get it working play with it - but know that you WILL have to THROW AWAY the code if the game ever gets popular OR you ever want to re-use the code for a future game.

Most people here like to re-use their code from half-made project to project, hence they worry about making something first time that is actually usable. If you're that kind of person, never ever ever think you can get away with "the client being a sort of server" - it will never work (modulo you can actually make it work, but in ways that are so much hassle and pain you honestly don't want to even think about going there).

malloc will be first against the wall when the revolution comes...
Offline sunsett

Senior Member




ribbit!


« Reply #7 - Posted 2006-10-30 16:39:15 »

Unfortunately I'm going to have to agree with blahx3h moderately.  One thing that you can do is "elect" a client to be authoritative (which I believe is how most P2P games work) but that's messy and problematic if the person you elect decides they want to cheat.  A server is always the best way to go if you can get away with it.  Even if you make the server just another client that can throw red flags if there's ever a dispute someone has to be able to overrule.
Offline Astrosmurf

Junior Newbie




Java makes your spirit soar!


« Reply #8 - Posted 2006-11-01 14:08:57 »

Sure, go ahead - Write the game, get it working play with it - but know that you WILL have to THROW AWAY the code if the game ever gets popular OR you ever want to re-use the code for a future game.

Most people here like to re-use their code from half-made project to project, hence they worry about making something first time that is actually usable. If you're that kind of person, never ever ever think you can get away with "the client being a sort of server" - it will never work (modulo you can actually make it work, but in ways that are so much hassle and pain you honestly don't want to even think about going there).

Hmmmm interesting.
I don't mind pain generally but when implementing... Naaaa..
Can you give an example of the "hassle and pain" with this approach? Not because I don't beleive you but of interest.
And thanks for the feedback, I will probably reconsider my network design.






If a problem has a solution, why worry? If a problem does not have a solution, why worry?
Offline Astrosmurf

Junior Newbie




Java makes your spirit soar!


« Reply #9 - Posted 2007-03-23 07:45:52 »

Now I've refactored the game into a pure server-client architecture.
And I must say it has really made development a lot easier and the code tidier.
So I must give you guys (or gals) cred for pointing this out to me. 

If a problem has a solution, why worry? If a problem does not have a solution, why worry?
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.

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (18 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (46 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56

mitcheeb (71 views)
2014-09-08 06:06:29
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!