Multiple/Single Instance(es) of Smartfox Object ?

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

Multiple/Single Instance(es) of Smartfox Object ?

Postby levancho » 06 Mar 2012, 22:02

Hi,

I have a more of, please advice, kind of a question in regards what would be the best practices of using smartfox Object on the Client side.

I went through he Samples and in SpaceRaces I see that it is spawning new smartfox Object for each window, so I was wondering what is the benefit of having multiple smartfox instances instead of just one?

my impression was that single instance was sufficient since for each instance it has to be connected to the server again and logged in?
that means I have to store user credentials ? or maybe if one smartfox instance is connected other instances will be automatically connected and logged in whenever the are created?


Please suggest

Kind Regards
Levan.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Multiple/Single Instance(es) of Smartfox Object ?

Postby rjgtav » 06 Mar 2012, 23:48

Hi.
Well, the SpaceRace Example uses multiple SmartFox objects to simulate multiple clients connected (for developing only purposes), each one in a window.
When developing a game, you just use one instance at a time. When you logout and disconnect from the server, when you want to connect again, you should create a new instance, replacing the old one.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
levancho
Posts: 71
Joined: 27 Jun 2011, 16:03

Re: Multiple/Single Instance(es) of Smartfox Object ?

Postby levancho » 07 Mar 2012, 13:54

Well, I am not sure, because I played SpaceRacer and it was working as realworld example,I dont know how creating multiple smartfox instances can simulate multiple users ?
as I see in source code it creates new instance of smartfox for each Ui windows, I am no sure if it needs that to simulate multiple users, there is something else going on, any other suggestions?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Multiple/Single Instance(es) of Smartfox Object ?

Postby rjgtav » 07 Mar 2012, 23:38

Well, the problem they faced while developing the SpaceRace Example is that Adobe Air, unlike Flash Player, doesn't let you run multiple instances of your application at the same time, you're limited to running only 1 instance at a time.
In order to facilitate debugging and for helping testing multiple clients with only 1 machine, A51 Integrated team (Space Race's developer) created that intelligent way of being able to test multiple clients (which represent multiple users) on just 1 computer. So, basically, it's like if each window was a different swf and client.

But when developing your own game, there'll only be one client per machine, and so you don't need to have multiple SmartFox objects running, 1 is enough.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 16 guests