tags:

views:

102

answers:

4

I'm developing a multi-player game and I know nothing about how to connect from one client to another via a server. Where do I start? Are there any whizzy open source projects which provide the communication framework into which I can drop my message data or do I have to write a load of complicated multi-threaded sockety code? Does the picture change at all if teh clients are running on phones?

I am language agnostic, although ideally I would have a Flash or Qt front end and a Java server, but that may be being a bit greedy.

I have spent a few hours googling, but the whole topic is new to me and I'm a bit lost. I'd appreciate help of any kind - including how to tag this question.

+1  A: 

If latency isn't a huge issue, you could just implement a few web services to do message passing. This would not be a slow as you might think, and is easy to implement across languages. The downside is the client has to poll the server to get updates. so you could be looking at a few hundred ms to get from one client to another.

You can also use the built in flex messaging interface. There are provisions there to allow client to client interactions.

Byron Whitlock
I am pretty fluent in Flex comunicating with a Java back end via AMF, and in fact my prototype game is developed in Flex. When I was developing applications in anger some years ago the Flex Data Services were part of Flex 2, now they have been spun out. It wasn't a good solution for the problem I had then and to be honest it still feels a bit heavyweight, but maybe I need to look again. I shall... Thanks for the answer. BTW I think latency will be an issue, so I have pretty much discounted web services.
Simon
+1  A: 

Typically game engines send UDP packets because of latency. The fact is that TCP is just not fast enough and reliability is less of a concern than speed is.

Web services would compound the latency issues inherent in TCP due to additional overhead. Further, they would eat up memory depending on number of expected players. Finally, they have a large amount of payload overhead that you just don't need (xml anyone?).

There are several ways to go about this. One way is centralized messaging (client/server). This means that you would have a java server listening for udp packets from the clients. It would then rebroadcast them to any of the relevant users.

A second way is decentralized (peer to peer). A client registers with the server to state what game / world it's in. From that it gets a list of other clients in that world. The server maintains that list and notifies the other clients of people who join / drop out.

From that point forward clients broadcast udp packets directly to the other users.

Chris Lively
what would I store on the server if I wanted to re-broadcast to a client? I think this is the bit I really don't understand, especially in an environment where the client may have asynchronously disconnected. What form does an address of a client take so the server can post messages to it?
Simon
All the server should need is 1. the "world" they are in; and 2. the list of clients ( IP / host) that it needs to rebroadcast to. You're going to have special problems like how to get past proxies etc. I would highly recommend you go to the local book store (or Amazon) and get a book on game development.
Chris Lively
A: 

If you look for communication framework with high performance try look at ACE C++ framework (it has Java bindings).

Official web-site is: http://www.cs.wustl.edu/~schmidt/ACE-overview.html

vnm
any idea how current and well supported this is? The whole thing looks a bit dated.
Simon
This string from readme of last release: "This is ACE version 5.7.4, released Mon Oct 12 14:03:48 CDT 2009".For more details and comparisons to other libraries look at "ace" tag of stackoverflow: http://stackoverflow.com/questions/tagged/ace
vnm
A: 

You could also look into Flash Media Interactive Server, or if you want a Java implementation, Wowsa or Red5. Those use AMF and provide native functionality for ShareObjects including synching of the ShareObjects among connected clients.

Those aren't peer to peer though (yet, it's coming soon I hear). They use centralized messaging managed by the server.

Good luck

evanmcd
Flash Server = US$4,500...
Simon
Yes, if you need a lower cost option, Wowza is cheaper and offers a seemingly very affordable EC2 option and Red5 is open source.
evanmcd