How to Get a Web Application to Communicate Between Users

djangogoogle-app-enginenetworkingweb-applications

I am developing a multipalyer web Application for Anti-Chess. It would be hosted on Google App Engine.

I have a few questions:

How do I get two different users who have opened the webapp on their browser to communicate moves with each other. P2P or through the server. If through the server, can I store some moves on it (specifically talking about GAE), to test bots later?

How to implement this P2P/Server connection. As a developer I know jack about Networking. But I hav heard of things like Socket programming, HTTP request etc, what can/should I use. And where can I read up on that!

If I don't go for GAE, would it cost me too much to get some server space and hosting capabilities? And people tell me that then deploying the application is tougher than on GAE. Is that so. Where can I read up on deploying the web Application on Servers.

Where does the code for networking go? I will be using Django with python as the web framework, front-end would be HTML, CSS, and JavaScript. Should I make a separate module for the networking methods and then introduce a method calls wherever needed in the game play?

Someone suggested me on using Unity software for developing. Is it good, Does it make it simple to do work? Will it cover all the parts of the development, the front end and the back end and the deployment?

Note: I am a first timer in web Application, I have coded games before, but always without GUI. And also with no multiplayer over the network capabilities!

Best Answer

If you want to communicate state between two participants in a game, one relatively simple way to do it would be to have a web service which allows each player to PUT the resource that represents the shared game state, with verification to make sure that they don't make illegal moves (or modify the other player's moves). This is an example of the logical flow:

  1. Assign each player a token, after they've authenticated (using an email, for example).
  2. Allow a player to invite another to play a game. This could take the form of sending a message to the other player, to which the other player could respond.
  3. If the invitee accepts, create a shared resource to which those two users have permissions, and communicate the URL to both player resources.
  4. Allow the web app to PUT representations of the game state to the shared resource. In the case of chess, a simple example would be to have a shared PGN file to which both users could write.

If you're interested in this approach, which would be an example of "SOA," or "service-oriented architecture," you might try SOA with REST or RESTful Web Services. This architecture is server-client oriented, not peer-to-peer; that has the advantage of being much simpler to implement.

You could implement your web services as separate routes within your Django project, and have AJAX calls from your Javascript front end which actually perform the actions related to the game state. I think Unity would be overkill for what you're trying to do; it's more about graphical games.

Related Topic