Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (843)
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  
  Newbie, need help on creating Real time network game  (Read 2253 times)
0 Members and 1 Guest are viewing this topic.
Offline diodoi

Junior Newbie

« Posted 2005-11-10 01:30:44 »

If I want to make real time game, such as multiplayer RPG across network, what kind of server client procedure should I use?
I have read the TCP/UDP contrast, but not sure how the achitecture would looks like ? anyone have source code to share or any info ?
Offline JAW

Senior Devvie

Medals: 2

« Reply #1 - Posted 2005-11-14 18:32:25 »

There is generally two ways to handle communication.
Central or decentral.

Central would mean,you have a server, everyone sends to it, server computes the game state and sends it to all players. Clients only do a "frontend" job, the server decides who takes damage etc.

Decentral means, everyone sends to everyone and you need a way that all clients make the same state out of it.

Basically the server version is easier to handle. Once the game starts, you determine the fastest client and make him server, for he has the greatest load. Every client does a simulation of the game, like a prediction of what he thinks what will happen. They send their interaction with other players to the server, the server makes it all up, solves conflicts and returns a situation to all clients. The clients make up the difference between the server message and his own prediction, which is usually not existent or too small to be noticed.

The major problem is synchronization. When you get a 300 ms delayed msg like do 10 damage to soldier 13, a lot of other stuff has happened.
Consider the following chain of events. Soldier A and B both have 5 HP health
1) PC 1, time 12: soldier A does 10 damage to soldier B
2) PC 2, time 15: soldier B does 10 damage to soldier A (he does not yet know that he is dead)

The server gets msg 1 and msg 2, sees that msg 1 happens first and decides, soldier b dies and does no damage
he sends to both PCs soldier A has still 5 hp, soldier B is dead

Now lets say message 1 takes 200 ms to arrive at the server for network reasons.
The server by then has recieved msg 2 and has decided to do 10 damage to soldier A and thus soldier A dies.
Later the server gets msg 1. Basically, he should kill soldier B and revive Soldier A, this would be "right" in the order of time.
But in gameplay it would be irritating. You might want to decide to let soldier B live and tolerate the error.

When playing RTS over network you might see that damage and death has a delay. I remember playing Starcraft, where enemy units sometimes die 200 to 400 ms after the hit, this is the server delay. You see the hit instantly, but the damage is computed on the server and returned to you.

You might encounter some trouble in handling delayed messages. First, messages will not arrive in order of time, so you must provide a timestamp and order them. But there is a maximal wait time, you cannot wait 1 second because there might be a late message. Youll have to drop messages with a too great delay. You can develop a really complex communication protocol.

The advantage in decentral commonication is, that only two interacting clients need to make up their stuff.
PC 1 would send 10 damage at time 12 to soldier B
PC 2 would send 10 damage at time 15 to soldier A
And then they make up a decision.
PC 1 would reply i do not accept your damage, the soldier B dies first
PC 2 can verify this and accepts it
thus you have a synchronized situation
After conflicts are made up, the tell all other clients the new situation.

Well, this is enough to give you an idea.

Offline GameDev101

Senior Newbie

« Reply #2 - Posted 2005-12-01 18:02:41 »

Your description is quite understandable, but im quit the n00b when it comes to networking gameplay... Im working on a project similar to this. Could anybody show me a way to implement this into an applet based mmo such as runescape?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline noblemaster

« JGO Spiffy Duke »

Medals: 35
Projects: 11

Age of Conquest makes your day!

« Reply #3 - Posted 2005-12-01 19:37:07 »

You might want to look at Apache MINA. I was using and java.nio
before, but I am currently changing my game to use the MINA protocol. MINA
uses NIO as underlaying transport protocol.

You could create some sort of protocol using NIO yourself, but I would
suggest you don't reinvent the wheel.
-> MINA simplifies message passing (belive me, it's cool to design your
    own protocol, but what you really want is create a game! Not a network
->Don't worry, it's fast enough to do real-time gaming

Apache MINA:

Offline Jeff

JGO Coder

Got any cats?

« Reply #4 - Posted 2005-12-04 20:25:26 »

How many players are you going to support in a agame session? if its a dowzen or less I wouldnt worry about NIO.  If its upwards of 50 then yes youll definitely need to deal with NIO at least omn the server.

HOWEVER I suspct youa re putting the cart WAY befor the hrose.

What kind of game experience do you have? Real-time networked games are the *hardest* type to write well.  If your just getting into game progrmming Id suggest starting with something much less ambitious.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!
Pages: [1]
  ignore  |  Print  

EgonOlsen (38 views)
2018-06-10 19:43:48

EgonOlsen (20 views)
2018-06-10 19:43:44

EgonOlsen (40 views)
2018-06-10 19:43:20

DesertCoockie (187 views)
2018-05-13 18:23:11

nelsongames (122 views)
2018-04-24 18:15:36

nelsongames (121 views)
2018-04-24 18:14:32

ivj94 (861 views)
2018-03-24 14:47:39

ivj94 (122 views)
2018-03-24 14:46:31

ivj94 (758 views)
2018-03-24 14:43:53

Solater (139 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!