Connect to a specific zone

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

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

Connect to a specific zone

Postby rjgtav » 30 Aug 2009, 14:39

Hi there. I was searching on the docs and i didn't find the answer to this. Is there a way to connect to a specific zone, not the server? the smartfox.connect(ip, port, zone) doesn't work. pls help me

*EDIT*

I've found another solution that works.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 31 Aug 2009, 09:12

When you call connect you simply establish a TCP socket connection.
At that level there is no notion of Zones. It is a low level network operation that allow two endpoints (client and server) to establish a channel of communication.

After this step the client can talk to the server via a specific protocol, in this case the SmartFox protocol.

The 2nd step is the login operation, at this point you specify which Zone you want to use, which in another words specifies which application on the server you want to use/interact with.

One client connection can use one Zone at a time.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 31 Aug 2009, 09:55

ty for the reply. Now the client first connects to see if the server is on, then logins and logouts in each zone (each zone is a server of the game) to get the users online in that zone. Then the player choose wich server wants to log in and the client makes the final login. :lol:
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 31 Aug 2009, 13:23

It is not necessary to do all this if you want to know the number of people in each Zone.
http://www.smartfoxserver.com/docs/docP ... /index.htm
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 31 Aug 2009, 14:51

Ty but i prefer use script that i understand and i don't want to use php to this.
sharingan
Posts: 36
Joined: 26 Oct 2008, 15:40

Smartfox application security issues

Postby sharingan » 24 Sep 2009, 03:51

Hi Lapo,

My problem is slightly different rjgtav's so hope you can help me out. Currently I'm doing a virtual world type game. The order of going into the game is as such.

1. Login page - user types in his username and password. Login details are sent via PHP to be verified against details in mySQL database.
2. Gateway selection page - user selects which gate he wants to enter
3. User enters the virtual world and has access to all the rooms in that gateway

I based the application on the Terracotta example that you emailed, but made slight changes to the python (ClusterAccess.py) file to return the list of available IPs (and port numbers) the user can connect to. This list of IPs is converted to the gateway selection page in number 2 above. Hence actually at the login page, the smartfox.connect and smartfox.login functions aren't called until after the user has selected the gate he wants to enter at the gateway selection page. Then the smartfox.connect is called, where it is connected to the selected gate's IP and port number, then the smartfox.login is called, based on the the user's username and password entered in the previous Login page.

Everything works fine, but now I want to:

1. Implement secure login as you outlined in http://www.smartfoxserver.com/docs/inde ... /index.htm at the Login page. How do I do that if the smartfox.connect is only called later at the Gateway selection page? I cannot call smartfox.login before smartfox.connect.

2. Make use of smartfox's detection of whether the user is already logged in, at the Login page. Right now I am using PHP and mySQL to check if the user is already logged in, when I check the user's login details.

Also, is there any way I can make use of smartfox's random key to send data to my database, other than the Login? Do I have to use a serverside extension all the time? Because currently, everytime I send POST variables from the client's Flash player, it can get intercepted by "hacking" software like Tamper Data. Please help!
sharingan
Posts: 36
Joined: 26 Oct 2008, 15:40

Postby sharingan » 25 Sep 2009, 06:39

Hi Lapo,

Would really appreciate your help! Before my game is released and it gets hacked!

Thanks!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 28 Sep 2009, 07:39

1. Implement secure login as you outlined in http://www.smartfoxserver.com/docs/inde ... /index.htm at the Login page. How do I do that if the smartfox.connect is only called later at the Gateway selection page? I cannot call smartfox.login before smartfox.connect.

I don't understand the question. Why would need to call login before connect?
Once the client has selected a gateway it will first connect to it, and then perform a secure login.

2. Make use of smartfox's detection of whether the user is already logged in, at the Login page. Right now I am using PHP and mySQL to check if the user is already logged in, when I check the user's login details.

Since you use MySQL and PHP to login a user, you will need to stick with that. The current system is okay in this case.
Lapo

--

gotoAndPlay()

...addicted to flash games
sharingan
Posts: 36
Joined: 26 Oct 2008, 15:40

Postby sharingan » 01 Oct 2009, 04:31

Lapo wrote:
1. Implement secure login as you outlined in http://www.smartfoxserver.com/docs/inde ... /index.htm at the Login page. How do I do that if the smartfox.connect is only called later at the Gateway selection page? I cannot call smartfox.login before smartfox.connect.

I don't understand the question. Why would need to call login before connect?
Once the client has selected a gateway it will first connect to it, and then perform a secure login.

Hi Lapo,

Thanks for the reply. Ok, to clarify the problem. Basically at the login page (the login page is an swf, within the same swf as the whole game), the client has not selected a gateway. Hence, smartfox is not connected. The client will enter his login credentials, which currently is being checked via PHP and mySQL. After that is checked, the user then gets to choose the gateway, after which only smartfox.connect and smartfox.login is called.

The problem now is that I want to check if the client has already logged in at the login page, i.e. before choosing the gateways. I know smartfox returns a "user already logged in" error whenever a client tries to login twice. However, because at the login page, smartfox.connect has not been called, i.e. I cannot call smartfox.login, I cannot make use of this feature. Any suggestions?

As for the secure login, are you suggesting I check the login credentials (use my own secure login methods via PHP and mySQL), then after the client selects the gateway, implement smartfox's secure login?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Oct 2009, 13:15

You have two logins here.
One happens via PHP and the other one via SFS.
You will need to use a database flag of some sort to coordinate the two.

The simplest thing to do looks like this:

1- check user credentials via PHP, if they are correct mark the User on the database as logged in

2- proceed with the SFS login. You will need a custom login that will connect the same database and double check the User flag.

This way a User will not be able to skip the first login and jump directly in SmartFoxServer.
Lapo

--

gotoAndPlay()

...addicted to flash games
sharingan
Posts: 36
Joined: 26 Oct 2008, 15:40

Postby sharingan » 05 Oct 2009, 10:41

Lapo wrote:You have two logins here.
One happens via PHP and the other one via SFS.
You will need to use a database flag of some sort to coordinate the two.

The simplest thing to do looks like this:

1- check user credentials via PHP, if they are correct mark the User on the database as logged in

2- proceed with the SFS login. You will need a custom login that will connect the same database and double check the User flag.

This way a User will not be able to skip the first login and jump directly in SmartFoxServer.

Thanks Lapo! Ok that means having to set a flag in the database.

One more thing, and think this may be a little off-topic for the current thread. Currently, based on PHP and mySQL, I seem to have some problems each time I change rooms. The users in the room I changed to seem to take a long time to load, and when I traced, I realise the lag comes mainly from during the time when PHP is requesting data from mySQL (to get the user's details). Once I've gotten the user details, the rest of the loading e.g. swf files related to each user, is quite fast. I'm not sure what the problem is but I suspect it's that PHP cannot handle so many requests especially in such a multiplayer environment. Just to clarify my loading process, it is as such:

1. User enters the room
2. On entering the room, loop through the user list using a for loop, and create each user's object class
3. For every instance of the user's object, send PHP request to get user data i.e. if there are 20 people in the room, there will be 20 PHP requests.

Is this the best way to get flash to communicate with mysql? If not, do you have suggestions for other methods that would be more efficient? My server is quite a high-end one, so it is unlikely a server problem. The use of mysql is necessary, however, as I have other webpages that will make use of the same data that my game uses.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Oct 2009, 14:19

I'm not sure what the problem is but I suspect it's that PHP cannot handle so many requests especially in such a multiplayer environment. Just to clarify my loading process, it is as such:

Yes that's correct. PHP doesn't scale well, you can't even compare it to SmartFox. :(
I wouldn't recommend putting much pressure on the PHP side because when the traffic grows it will be a huge bottleneck.
If you need continuous interaction with the database you will need to integrate db access in SmartFoxServer from server side. This will give you much better performance and will allow you to fully exploit the potential of your DB

1. User enters the room
2. On entering the room, loop through the user list using a for loop, and create each user's object class
3. For every instance of the user's object, send PHP request to get user data i.e. if there are 20 people in the room, there will be 20 PHP requests.

This is quite crazy :D and won't work when you reach 100 users or more.
The only way to do something like this is using User Variables in conjunction with server side code that talks directly to your database.

You can find a lot of documentation on these topics in our docs area, including examples with source code. Start from chapter 6.
http://www.smartfoxserver.com/docs
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 32 guests