PDA

View Full Version : how to know a connection is down


miguelp
06-12-2007, 03:45 PM
hi, i run into a problem, that's to know when a connection is down, i have a flash movie that interacts with PHP in the server side, it has data going back and foward from flash to PHP and back to flash, the problem is to test when the connection to the server is down, because i have to freeze that flash movie when the connection goes down.

I have no idea how to test that.
Any sugestions?

Paul Ferrie
06-13-2007, 09:34 AM
Are you wanting to check if the server is down or a connection to the database?

miguelp
06-25-2007, 12:13 PM
the server, when i have a game done in flash that hame some comunication up and down to a PHP scripts in the server side, i whant to be able to know when the connection is down so i can gracefully show an error message to the user, and dont show him a bunch of "undefined" in the screen.

Paul Ferrie
06-25-2007, 12:32 PM
when i have a game done in flash that hame some comunication up and down to a PHP scripts in the server side,
What are these scripts doing?

miguelp
06-27-2007, 02:50 PM
theyre sending the user choices to PHP so it can process them and return some values. on example is a slot machine, i get the balance of the user from PHP then the user place his bets, i send the user bets to php that processes the request, generate a sequence, and update the database, then php sends back to flash the sequence, the total wins, and the individual lines where the user win, and finaly the actualized balance.
so when a user sends his bets i need to know that i can reach the server if for some reason (internet connection down for example) i cant reach the server it has to say something so i can stop the entire game and tell the user the connection to server has been lost. thats basicly what i wanna do.

icktoofay
06-29-2007, 07:37 AM
I spy trouble... someone could cleverly modify the inbound balance request before it gets to Flash Player, and their balance could be super high! Not like this is a security forum though... Still, you'd probably want to encrypt it in a real-real-world application.

miguelp
07-05-2007, 04:20 PM
all the comunications between the flash and the server are made via HTTPS, with certificates, probably is not that easy to change anything. anyway the balance is allways sended by PHP and reconfirm when flash makes a request.

What i'm trying to do, is just came up with a way to know if the comunication have been broken during a request to server. If i send the request, but dont get the response. Its something like that i wanna implement.

Paul Ferrie
07-05-2007, 04:30 PM
You could create a timeout timer give x amount of seconds to check whether the request has been received or not.

miguelp
07-05-2007, 07:34 PM
well, i have been trying to do something like that using the setInterval() but i cant get it to work... can you please give a little example of the implementation of that timeout?

miguelp
07-10-2007, 04:34 PM
ok here's an example of the connection code i have so far:

function gere_opcoes(valor) {
switch (valor) {
///////////////// Fase 0 //////////////////////
case 0 :

var enviados0 = new LoadVars();
enviados0.opcao = 0;
var recebidos0:LoadVars = new LoadVars();
enviados0.sendAndLoad(filepath,recebidos0,"POST");
recebidos0.onLoad = function(succes:Boolean) {
_root.varsaldo = recebidos0.Balance;
};
break;
}
}

how can i, implement the time out on each switch option?