Page 1 of 1
Sending/Recieving data to/from db constantly
Posted: Mon Feb 27, 2006 10:48 pm
by davidprogramer
Anyone that knows anything about what I am talking about please reply with your thoughts.
We are trying to figure out a way to update the database with ALL of the match information WHILE it is taking place/completed.
1. Meta Tags - NO WAY! constant refreshing on a person that is trying to play a match would KILL their bandwidth/cpu/memory.
2. Stream - NOPE, would kill the site and player bandwidth...bad
3. Third-party program - Depends on how it is constructed. This is where I need your help. We came up with this idea so far:
a. You send a challenge and window pops up
b. The status is refreshed every 10 seconds until it is accepted and you are sent an encrypted file created by the server containing the challenge information
c. The file is constantly updated throughout the game (any change in server options/players/score is recorded along with the unix timestamp of when it happend).
d. When your done, you click "done" and it the script decrypts it and sends the info to the db, then deletes the local copy.
That MIGHT work....for a few days until someone either breaks the encryption.
Any other ideas would be GREATLY appreciated.
Posted: Mon Feb 27, 2006 11:00 pm
by josh
How would a refresh every 1-2 seconds kill bandwidth? Most users are on DSL / cable (especially the demographic of gamers) .. or at least I would think
What is the data being sent.. 6-7Kb? you're talking a minimum download rate of about 3Kb/s, a dialup user can easily hit that.
Solution to your other problem.. don't trust anything coming from the user. For instance in an RPG don't have the user send you his position, rather have him send you the direction he is moving and the speed, calculate the position he should be at and send it back to the client. Have the client adjust the player's position each time. The only downside of this is the position can jump around during lag, but this happens in every online game. Anytime an action occurs, for example picking up an item, send the action to the server and have the server send back the result of the action. You can only trust the data you calculate for yourself and know to be true.
Posted: Mon Feb 27, 2006 11:35 pm
by davidprogramer
Well the problem is, and I tested it, when you constantly refresh a page every second, it reloads the entire page causing cpu usage to skyrocket.
By the way, its one problem. I am trying to come up with a way to constantly update the database nonstop while they are playing the match so that they dont have to report the match.
Posted: Mon Feb 27, 2006 11:40 pm
by feyd
Sounds like bad page logic if a simple refresh can cripple your server.
Posted: Mon Feb 27, 2006 11:49 pm
by Trenchant
Whenever I hear constant refreshing, database connections, and user input I think flash. I find it very helpful in those situations.
There is always the arguement that some people don't have it. When you think about it though. Most do and if they don't they install it when needed.
Posted: Tue Feb 28, 2006 12:04 am
by davidprogramer
No I mean using a meta refresh to refresh the page constantly on the players end. Which causes the players cpu to spike. Which is really hard to work around. The server is fine though. Is there a way to keep loading the page without it messing with the players computer speed and bandwidth?
Can flash do that btw? I don't know ANYTHING about flash. Would it be hard for a beginner to do?
Here is a FULL explanation of what I am trying to do:
1. A 2v2 match between Clan A vs Clan B. Clan A puts in the challenge that the match will be started 7 minutes from the time Clan B clicks Accept. A popup for the Clan A challenger occurs, with a timer (that has NOT started yet, and a status message saying "Sending Challenge", "Challenge Sent, waiting for reply, 10 minutes to accept or reject before challenge is void".
Do NOT close the window. Tthe best way to reschedule it or other wise cancel the match is to click "Cancel the match" which will be an option on the page. BOTH clans will have to click it for this to work. A new status message will appear letting you know if the opposing clan has opted to cancel as well. If they dont, you better get in the server and play anyways. If you want to forfiet the match you will click forfiet.
2a. Clan B accepts and recieves a popup. The 7 minute timer ticks down. Everyone gets in the server within 2 minutes. They all warm up, talk, etc till the timer ticks to 0. When it reaches 0, a chime is sounded to the players with the popup (whoever accepted for clan A and clan B).
2b. Clan B accepts and recieves a popup. The 7 minute timer ticks down. Clan A enters the server but one player from Clan B enters. Clan B is forced to play a 2v1 and recieve half the points he would have recieved if his partner had joined.
3. Timer is stopped at 0, Any player that enters after 0 will be logged and the clan of that player will be forfieted. If a random player enters, the match is voided. So set a password. An LO3 is done by Clan A. The auto-report picks up on 3 resets in a row done by the server and records ALL stats done after that, mistakes are mistakes after that point. If a player leaves durin the match, he/she is not allowed back in. (We are currently working on a way to detect or somehow know if someone is banned or kicked from the server.)
4. The match ends. Clan A won. The popups status message displays who won and what the score was. The popup then sends the info of the match to the database. And the status of the message displays whether or not the info was sent successfully. If it wasn't, you can click "Send match info to Support", so they can figure out what happend and do a manual report of the match. If you close the window and the match doesn't get sent, match is considered as is with no guarentee of it being fixed.
By the way LO3 means resetting the current map 3 times thereby resetting all stats and refreshing the map basically.
Now, this would be really easy if I could figure out a way to constantly update databae tables and not eat the players cpu and/or bandwidth.
Posted: Tue Feb 28, 2006 12:13 am
by feyd
Anything running on their machine, let alone using their bandwidth affects those things, so no. Flash will often use more CPU. Seems like something needs rethinking...
Posted: Tue Feb 28, 2006 12:17 am
by davidprogramer
feyd wrote:Anything running on their machine, let alone using their bandwidth affects those things, so no. Flash will often use more CPU. Seems like something needs rethinking...
Any possible way to take the information from that script and put it in the database? I don't care how it's done honestly. I could probably put a script on the server to run, but I don't know how to program anything other than php really well enough to do that. That is the only way to do it probably though (having the site server sniff the IP's locally and update the db). I wouldn't know where to begin if I did it that way though.
jshpro2 wrote:How would a refresh every 1-2 seconds kill bandwidth? Most users are on DSL / cable (especially the demographic of gamers) .. or at least I would think
Yeah but it would murder their cpu. I am running a p4 2.5 ghz and it was slowing stuff down on my pc instantly. (My normal cpu use stays at about 2% max, it spiking from 20 to 35 consistantly staying above 20.)
ALSO
When I say meta refresh I mean this:
http://www.aowars.com/modules.php?name= ... id=&rcid=1
Now, that runs a little smoother, because its only loading text, no images and no queries to the database. If I put images and sql queries in there it would cripple the cpu.
Posted: Tue Feb 28, 2006 1:10 am
by Benjamin
Maybe you can use Javascript to add a tiny 10ms delay. I don't think 10ms would hurt too much and it wouldn't be so cpu intensive. What you have there is like an endless while loop.
Posted: Wed Mar 01, 2006 2:27 am
by davidprogramer
I just tested it again. If I take all images out and everything, meaning I only have text and sql queries, the cpu is fine and can easily play a game. The only problem doing this, is that if they simply stop the page, it stops sending information. =\ Would it be possible to use a frame and just refresh that over and over and not allow it to stop? I am tryin to figure out how to do this without the user being able to work around it and eventually cheat.
I started thinking. I could probably use a java applet? I don't know about using flash, it would get confusing if I used flash. But using java, I could possibly take the data that is sniffed and throw it in the database, voiding the reset results if they stopped the page or refreshed it.
Posted: Wed Mar 01, 2006 3:31 am
by patrikG
Have a look at
http://www.digg.com/spy
Basically, I don't understand at all why you would want an entire page to be reloaded. Just "feed" the bits necessary on the page with relevant data.
AJAX could offer you a solution. Google for the various AJAX toolkits. Quite powerful stuff.