Player A makes a move -%26gt; the information is sent to a server -%26gt; it is written to a database -%26gt; Player B gets a refreshed information every second -%26gt; Player B notices that Player A had moved.
The problem is, it uses server too much. How do I make an application in that way, that only the chosing of the table and then later the winner written to a database is done by a server while not loading it heavily with each move?
I have no idea how this connection to another user is done, but I know, that such things had been done in Skype. That means there is a method.
I would really appreciate any help!How do I make a web application connect two people?
By your description, you want a peer-to-peer type connection (i.e. the clients connects directly to each other, the server is only used to find each other)
For a web application, the complexity of creating p2p connection is outweighed by the simplicity of just relaying the message through the server. Often it requires user-interaction to setup p2p connection and sometimes it is just impossible to create a p2p connection (such as when both clients are behind a NAT router).
Skype uses p2p type connection because voice and video bandwidth is heavy. Simple message transmission like multiplayer games should just use a traditional server-client mechanism.
The server should not use database to store each and every move. Database is for permanent, long-term storage.
Let's see your current tactic:
Player A makes a move -%26gt; the information is sent to a server -%26gt; it is written to a database -%26gt; Player B gets a refreshed information every second -%26gt; Player B notices that Player A had moved.
- You're writing to database every turn. This is unnecessary, you could just use some sort of array that stores all currently-running game data.
- Player B gets full refreshed information every second. This is unnecessary. You could just transfer the move player A has made and some sort of NOCHANGE response if player A hasn't made any move at all.How do I make a web application connect two people?
Go to facebook
and login
No comments:
Post a Comment