Jump to content
  • Advertisement
Sign in to follow this  

How does Mix of Async/Sync server works in games like chess with friends

This topic is 1225 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


the Async part is quite well Understandable, but how do they combine the sync part , when the user see the other player moves

when he stay in the current session .

does it make poll requests every N seconds?

what is the architecture of the server behind such game that mix Async and Sync game 
i open to suggestion about server language or architecture i can use any ,,,

my client is c++ and i open to embed any thing in the client . 


Edited by umen242

Share this post

Link to post
Share on other sites
It seems to me that you have a server setup, language, or a framework in mind while asking this question, but you forgot to write about it in your post.

There are only 3 ways to get new information to a client, afaik:
- The client asks for it (polling)
- The client waits for it (blocked call to the server until the information is available)
- The server pushes it to the client when it's available (client waits until it arrives in its 'inbox')

All three are valid solutions, with their advantages and disadvantages
- polling: simple, costs bandwidth and cpu time
- blocked call: Server is more complicated, and needs to keep an administration of which client got what information. Also needs a stable connection. Client must be able to do multi-tasking (if you want to do other things besides being blocked at the client side).
- push: Needs a stable connection, and an administration.

You can also do mixes of things, have a client poll at a low freuqency, and have the server send a "new mail! come and get it" message when something happens.

Not sure how this relates to your Sync and Async concepts. Are they network concepts, or is it just the idea that "things happen in real time"? Note that what we perceive as "real time" can be several communications in the network, since we think in seconds, and networks think in fractions of seconds.

Share this post

Link to post
Share on other sites

Thanks for your answer , i update my , 

i will try to clarify more . 

what i mean Async is  ( again chess with friends example ) 

1. user adding  Competitors  <- async request 

2. user go to Competitor no' 1 make move -> async request 

now here is my problem 

if user stay in the chess board he can see the Competitor move his Chess Soldier so this is the sync part . 

so while im writing this , i guess when the user in this state the client start to make small polling requests . ... or not .

i just what to learn more about this type of architecture . 

Share this post

Link to post
Share on other sites
In network terms, you can only send messages or wait for messages (or both), where message is quite literally a the digital form of a note at a piece of paper. There are size limits to the paper, but let's not go there now.

What you describe as "async request" is not a single message.
For example "user adding competitors". It needs an exchange of messages to know who you are ("user"), you need to get a list of competitors, and you need to send a subset of that list back. So it's not one request, it's at least 2-3 messages that fly across the network.

To get a better understanding, I propose that you play a game of network. Find 4 players, and find 4 pieces of paper, write "me", "server", "one friend", "second friend" at the top, and put them at separate places in your house or room. The piece of paper represents the knowledge of the person in the game. Each player also gets a load of small notes, and a pen to write the messages.

The rule is that each player may only use information he knows by himself, or information from the piece of paper. (This is the hard part of the game, you are easily tempted to use more information than you have according to the rules).

Everybody can send a message, a short line of text of a few words (say, less than 8), a question or a statement. The server can send to anyone else, all others can only send to the server.
You send a message by writing a note, folding it, bringing it to the other person, and leaving without a word (going back to your paper).

When you get a message from someone, you may read the note, copy any information from the note to the paper, and then discard the note.
You may also modify or delete the information on your own paper as you like.

Now try to do 1 and 2 in that game. You'll be surprised how many notes you need to exchange (especially the server) to get agreement.
In the same way, you can also try different ideas in what you call "sync request".

At a more serious level, the thing you are trying to understand is called "protocol". A protocol is a set of messages that have a properly defined (and agreed) meaning. For example, if I say "Hello", you know that I mean to greet you, rather than I expect you to pay me a thousand dollar. We both know the message "hello" and we both agree on its meaning.

There are lots of protocols, and there also exist protocols for chess playing, eg https://chessprogramming.wikispaces.com/Protocols?responseToken=e7442a33e8385089777b3984be5a04ea I am sure there are many more, just search the Internet a little.

Share this post

Link to post
Share on other sites

Hey thanks for your answer , 

now i realy looking for some open source example for a sync simple games . 

Share this post

Link to post
Share on other sites
How about various open source GNU chess clients?
XBoard and PyChess are two (C/C++ and Python, respectively.)

Note that the chess protocol uses straight TCP sockets; it does not overlay on top of another transport like HTTP.
If you're looking for an answer to the question "how do I layer a game on top of HTTP requests" then that's a harder problem.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!