Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (117)
games submitted by our members
Games in WIP (564)
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  
  RTS networking setup - what is best?  (Read 3134 times)
0 Members and 1 Guest are viewing this topic.
Offline xannus

Junior Newbie




Mutalisqette


« Posted 2009-10-06 17:36:46 »

Hi

I previously made an RTS, network playable.
It functioned by having the game divided into frames, each frame basically being the game loop.
Each player/client had to send a datagram containing movement info for that frame to the server, which was relayed to each client.
Is this the reccomended way to do the network aspect... with datagrams?
or is there an input / output stream, preferred way?

JamesHancock<br />jameshan24@yahoo.com
Offline Eli Delventhal

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #1 - Posted 2009-10-06 19:09:37 »

I think people typically send the moves back and forth with Sockets (by moves I mean the keyboard input), often along with timestamps. But that's mostly what I've observed here, because I've only made a couple networked games and they weren't at all sophisticated.

See my work:
OTC Software
Offline princec

JGO Kernel


Medals: 380
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #2 - Posted 2009-10-06 19:40:20 »

Probably a combination of UDP and TCP is what you might want, though for something like an RTS I have a feeling UDP won't be so useful as it is in FPS type games.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Hsaka
« Reply #3 - Posted 2009-10-06 21:59:41 »

For the RTS that I made, I found that TCP and Lockstep sync worked well.
http://hsaka.webs.com/lib/ninjawars.jnlp
Offline xannus

Junior Newbie




Mutalisqette


« Reply #4 - Posted 2009-10-09 13:04:16 »

Thx, all,

I'd like to go with TCP, then.
Would that mean each player/client has a connection to every other client? relaying out timestamped activity info?
Isnt that a serious burden, or will an array of OutputStreams and a separate array of InputStreams be quite managable? 

So, would my client constuctor take an array of outputstreams and InputStreams, or IPaddresses? Should I choose any port number for my game?

JamesHancock<br />jameshan24@yahoo.com
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #5 - Posted 2009-10-09 13:17:25 »

Would that mean each player/client has a connection to every other client? relaying out timestamped activity info?

No ! That would be a hell to synchronize everything .
You should either have a centralized server in a dedicated machine, or have one of the players to host a game (but that would lead to a lot of issues for people behind NAT) . Then all players connect to the server .

In both cases, each player send their actions to the server  .  The server then validates it and broadcast to other players .
In short, that's it .

Maybe you should try and create a simple chat application with the same architecture before moving on to your RTS. You'll learn a lot and anyway you'll probably want to reuse the code for an ingame chat .

Offline xannus

Junior Newbie




Mutalisqette


« Reply #6 - Posted 2009-10-09 15:26:56 »

Thanks

So, something like this...?

In my main(  I create two instances of ChatClass,
both with localhost addresses...
With an ObjectOutputStream on one connecting to an ObjectInputStream on the other?
And I have both with chat windows ...TextArea, Textfield
?
There should be no firewall issues with that?
Thanks


JamesHancock<br />jameshan24@yahoo.com
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #7 - Posted 2009-10-09 16:17:02 »

I didn't quite understand what you meant, but I think it's not a good idea to implement a "client-server" , if that's what you meant . Some games do it like this, for example Tetrinet .
I think it's better if you write just a server, and then both clients connect to it (even if one of the clients is localhost) . this way you can keep things separated and organized, and you dont need to deliver your server to every client .

The server should wait in a thread for incoming connections, with socketServer.accept() , and as soon as a connection is established, put this connection in a list . Each connection instance in the server will have an input and output stream . When a client sends a message (client output stream -> server input stream) , iterate in this list and send the message to all clients (server output stream -> N client input streams) .

I think that should be enough for you to begin with . Afterwards you have to deal with stuff like connection loss, concurrency, etc , but I wouldnt care about that now .

Good luck

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 800
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #8 - Posted 2009-10-09 16:20:26 »

I'd advise you to start with a line based (text based) protocol. You can dump the stream into a file (or to the console) which makes debuging a breeze.

Later, once you are confident that everything works as you like, you can switch to a binary protocol, but often you don't have to. If you think that this makes it too easy for cheaters, well, they don't seem to have much problems figuring out binary protocols, so why bother with security by obscurity. You can make a text based protocol just as safe as a binary one.

ObjectInputStreams / ObjectOutputStreams can be very surprising, if you haven't read the javadoc top to bottom.

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

JGO Kernel


Medals: 165
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #9 - Posted 2009-10-09 17:54:32 »

This is how I did it quite a while ago:

http://www.cokeandcode.com/rtsnetworking

About half way down the technical bit starts. I like lockstep synchronization but I hate the one laggy client lags out everyone. The article talks about loose step approach which doesn't have that problem.

Kev

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.

Grunnt (23 views)
2014-09-23 14:38:19

radar3301 (14 views)
2014-09-21 23:33:17

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

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

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

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

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

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

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

TehJavaDev (108 views)
2014-09-10 06:39:09
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!