Issue with games using Web Server

BlitzMax Forums/BlitzMax Programming/Issue with games using Web Server

Rambo_Bill(Posted 2005) [#1]
Okay, I'm trying to make games that use a standard webserver to communicate between them. I have it working fine for things like authenticating a login and posting hi-scores, but dynamically signalling each player of events effectively seems to be a problem.

The Problem Scenario (Two Players):
Using a BlitzMax client program and an ASP/ASP.NET webserver running MySQL. No chance of using CGI.

1. It's player ones turn, he has 60 seconds to move, but moves in 3 seconds. His move is communicated VIA http
2. How do I effectively signal the other player from the webserver that player one has moved? the keyword is effective, because I could have player 2 constantly query the server via HTTP or have player 2 query with delays,but this introducea delays into the game or causes load on the server. I'd prefer the ability for the server to be able to directly send player 2 the message, I am maintaining sessions, so there is a constant TCP connection between player 2 and IIS on the webserver. So if somehow I could signal IIS to send a page to a particular session user, but I think that is near impossible.


Any ideas anybody? Anybody know of any code samples doing this?


Jeroen(Posted 2005) [#2]
i recommend not using the method you described.

Authenticate a user fromout the game to a ASP/PHP script (that perhaps connects to MySQL database). For example, if you send user "john" and password "blah", you might turn this into a return code server-side, or MD5. E.g, it returns "xYc56pOo". If you use the same decryption process client side, you can check wheter the user/pass is correct.

First, I did this by returning 0 (incorrect login) or 1 (correct login) when authenticating, but hackers may simply write a PHP script outputting 1, always...Which returns in an invalid authentication. They can somehow hack the URL inside your executable, the URL you are connecting to.

This will somehow simulate a session.

The rest of the game can be plain UDP/TCP connections. Do not involve the webserver until you need to update highscores etc. Using the webserver makes the network traffic much, much too slow.

EDIT: You might be able to pull off the system you described, but only if you have permissions for CRONjobs (linux thing: being able to automaticly run scripts without the user quering)


Rambo_Bill(Posted 2005) [#3]
1.
Using the webserver makes the network traffic much, much too slow.
Tell this to Microsoft and Yahoo. Microsoft and others run MMGs where all communication goes through the server and then is passed to the clients. Seemed to work for Asherons call. Yahoo multiplayer games all go through the server and seem to work fine. I've played seven player Texas Hold'em with no lag on yahoo.. My PC was only communicating to yahoo's server. Also, I've used IRC servers which have thousands of chatrooms that were experiencing no problems (Again server based technology). ID Games quake series all use a centralized server, there is NO communication between clients directly (I know this because I did some programming surrounding Quake 3 Networking). So please do not repeat that quote again, as many popular reliable multiplayer games have used a centralized server. Only one I know of that didn't was Microsoft Generals, but that was buggy as heck.


2. So you are saying all the clients should be communicating between each other? This would be a major problem because of firewalls. If there was a way around this issue than this would be awesome.

3. I have a login from Blitzmax that sends the username and password to an ASP page using various encryption techniques, I then check a mySQL Database server.. After seeing the password/username are correct, I send back to the client various information to use in future communications. Adding to security is that the HTTP connection is remained constant, therefore the sessionid does not change and can be used along with other data to validate the user each communication.

EDIT: I can run jobs at schedule times on a windows box, but this is not effecient. I might as well have the client query the server at a regular interval (Wasteful)


Tom Darby(Posted 2005) [#4]
Rambo_Bill,

I second Jeroen's recommendation for using the website to act as an initiation point for a P2P connection between the players, then having the game client pass time-sensitive notifications (i.e., "Player X has made his move") directly between the clients. Then, you can either have the entire game play out as P2P, or you can use this P2P connection to minimize traffic to and from the web server (if, for example, you want to do server-side validations, or if you want to track scoring and statistics.)

You'll encounter issues with NAT addresses and the like, but it's a far more elegant solution than trying to use HTTP or another query/response-based protocol to pass real-time information.

(In general, the games at Yahoo! and Microsoft do not repeatedly query an HTTP server--rather, they'll communicate through a direct connection to a game server, thus minimizing network traffic. That, and Microsoft and Yahoo! both have more bandwidth than God, which I'm guessing is not the case for you. :] )


Rambo_Bill(Posted 2005) [#5]
I appreciate your responses, but I kindly disagree with your assessments. It may be because you don't understand that the most important thing for me to consider is the security and reliability of the game since it will be for money.

It appears best option is to have hosting that allows you to run executables then you can make a custom port 80 handler for a game server. I am going to put together a server at home to get everything working then I'll have to buy a non-shared server that allows for custom executables. As far as bandwidth, the games will cost money to play, so the more people who play the more bandwidth I can buy. These games are not high bandwidth users. I'm talking simple stuff like card games and the like.

Hmm, I wonder if a linux server running a Blitzmax linux compile of a game server would be better/faster than a windows box running a windows compiled version.. I'll probably stick with Windows since it's what I know best, but I dont have a copy of Windows 2003 server, so I'd save money if I did the linux.