Hi!
I've got a problem when I'm trying to use remoting on server side of
Communication Server. For example I want to make authorization system. I've got
remote function getMyFunc which returns PASSED or FAILED. My Server Side Code
looks like:
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////
load("netservices.asc");
application.onAppStart = function() {
NetServices.setDefaultGatewayUrl("http://myHost/gateway.php");
this.gatewayConnection = NetServices.createGatewayConnection();
}
function TestResult(client) {
this.client = client;
}
TestResult.prototype.getMyFunc_Result = function(res) {
application.authResult = res;
trace("Result:" + res);
}
function CheckUser(Username, Password) {
var myService = application.gatewayConnection.getService("test",
new TestResult(this));
myService.getMyFunc(Username, Password);
trace("CheckUser Result: " + application.authResult);
return application.authResult;
}
application.onConnect = function(clientObj,userType, Username, Password) {
trace("application.authResult = " + application.authResult);
application.authResult = "FAILED";
if (CheckBroadcastUser(Username, Password) == "PASSED")
application.acceptConnection(clientObj);
else application.rejectConnection(clientObj);
}
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////
The problem is, that this script always will reject the connections! The
problem is, that in code
myService.getMyFunc(Username, Password);
trace("CheckUser Result: " + application.authResult);
return application.authResult;
getMyFunc executes for few second (just becouse it is remoting call), and
Flash Interpretator just DON"T wait while it executes and continue working.
Thats why it just returns "FAILED" all times.
In few seconds after reject was done in AppInspector I'll see the "Result:
PASSED" - but it is too late!!!!!!!!
How can I slove this problem? Is it possible to hold executing remote function
for a while?
Stefan Theusner - 19 Aug 2005 17:21 GMT
Hi,
flash send the request to the server but will never wait for the result.
flash proceed with the code after your 'myService.getMyFunc(Username,
Password)' invokation.
Flash uses the _Result method in your object to pass the server result
by. So you have to continue in this method with your depending
application code.
It is not recommended to "stop" the whole application while waiting for
the server result.
The same applies to XML.sendAndLoad.