Forum Multiplayer Why is PlayerIO connect not reentrant?

Discussion and help relating to the PlayerIO Multiplayer API.

Why is PlayerIO connect not reentrant?

Postby TomatoGG » July 28th, 2010, 5:40 pm

Hi, I'm facing a problem where I need to be able call PlayerIO.connect again to try to re-connect upon a network error without having to refresh the entire game but the connect function is not reentrant as it keeps throwing the previous apiError. I am not expert to understand the code in the connect function but I added a small reset function to the PlayerIO class to clear the PlayerIO variables and it works. I didn't want to change the API but the variables are private so i can't clear them externally. I'm wondering if there is a reason why connect function is not reentrant and whether my code may not be the correct solution.

Code: Select all
public final class PlayerIO
{
   public static function reset()
   {
      wrapper = null;
      queue = [];
      apiError = null;
   }
      :
}
TomatoGG
 
Posts: 17
Joined: July 3rd, 2010, 11:15 am

Re: Why is PlayerIO connect not reentrant?

Postby fox1980 » July 29th, 2010, 1:31 am

I'm not sure i understand your problem. At least such behaviour never happened to me (the part about throwing the previous api error when calling connect again). Can you post some more code, specially the connect statement ?
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Why is PlayerIO connect not reentrant?

Postby Benjaminsen » July 29th, 2010, 10:58 am

I would very much like to see the error as well, there should be no need to redownload bridge as you are doing.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Why is PlayerIO connect not reentrant?

Postby TomatoGG » July 30th, 2010, 1:04 am

Ok i have uploaded two versions of my game, the first one is using the original PlayerIO API without modification.
When the Sign-In screen appears, disable ur network or remove the network cable and then click on the OK button
and my game will try to call PlayerIO.connect which after a while will fail and you get the apiError.
Close the error dialog to return back to the Sign-in screen and even if you re-connect the network,
you still get back the same apiError if you try to connect again.

http://www.bunco-jackpot.com/bunco2

Im not doing anything special except just calling PlayerIO.connect function again with the same parameters.
The following is the one where i added and call the reset function in the PlayerIO class.
Even though the network is disconnected the first time you try to sign-in, if you connect the
network back, you should be able to Sign-In without getting the apiError.

http://www.bunco-jackpot.com/bunco
TomatoGG
 
Posts: 17
Joined: July 3rd, 2010, 11:15 am

Re: Why is PlayerIO connect not reentrant?

Postby TomatoGG » July 30th, 2010, 9:54 am

Benjaminsen wrote:I would very much like to see the error as well, there should be no need to redownload bridge as you are doing.


But what if the bridge could not be loaded in the first place because of a network error? I looked at the proxy function and the first line looks like it will always throw any prior apiError and does not attempt to reload the bridge again. I hope i am using the right version of the API. I'm using the API from the NewGame project in the Flash Combo Package 1.6.

Code: Select all
private static function proxy(target:String, args:Object):void{
   if(apiError){
      throwError(apiError,args[args.callee.length-1])
                              :
}
TomatoGG
 
Posts: 17
Joined: July 3rd, 2010, 11:15 am

Re: Why is PlayerIO connect not reentrant?

Postby Benjaminsen » July 30th, 2010, 10:11 am

Fair point, if downloading the bridge fails the system will most likely totally break. I will look into making it more robust, but it is a nice to have, as people with so flaky connections will have a hard time using the service in general.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark


Return to Multiplayer