Two simultanious logins from the same user?

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

Moderators: Lapo, Bax

noamgat
Posts: 10
Joined: 02 Dec 2009, 14:15

Two simultanious logins from the same user?

Postby noamgat » 04 Dec 2009, 16:39

Hi

I'm currently working on an app that connects to SFS in two different layers - the lobby layer (written in flash) and the game layer (written in unity).

I don't have a way to pass the actual connection between the two, so I pass login data from one layer to the other.

The problem is that I get an error in the login ("This username is already taken"). Is it possible to allow the server for a user to be logged in twice at the same time? Will the server allow me to be in two different zones in the same time with the same user?
If not, what is the recommended workaround for this kind of design? (The chat windows are still visible and should be usable during the game)

Thanks!
starzero
Posts: 28
Joined: 19 Jun 2009, 18:41

Postby starzero » 05 Dec 2009, 14:50

how about running another instance of sfs on a different port and have your unity client connect to that one? ... I think that would work fine unless you have information that needs to be available in both your flash client chat lobby and unity game client.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 07 Dec 2009, 08:52

Instead of two servers you can simply use two Zones, one for the Lobby and one for the game(s).
SmartFoxServer does not allow duplicate names only under the same Zone.
Lapo
--
gotoAndPlay()
...addicted to flash games
starzero
Posts: 28
Joined: 19 Jun 2009, 18:41

Postby starzero » 07 Dec 2009, 13:26

ah ... good to know, Lapo
noamgat
Posts: 10
Joined: 02 Dec 2009, 14:15

Postby noamgat » 07 Dec 2009, 20:59

Ok, so if my original design had one zone per game, I'll need to change to one 'matchmaking' zone and one 'gameplay' zone per game.
I can cope with that.
Sac_zeal
Posts: 5
Joined: 21 Dec 2009, 09:41

Postby Sac_zeal » 21 Dec 2009, 10:10

Hi Lapo,

We are working on a similar kind of project, we have Lobby in AS, and Game in AS. And we have the same problem which we want to sort out.

Prologue:
We are starting with one game right now, and are planning to scale up to more games as it comes, with one lobby for each game. The current game has multiple modes, So we planned of using the 3rd type of architecture in the doc. Where the lobby will use an AS extension and each game mode( same game various modes) be created in one room with the game server code in AS extension.

Questions:
1. Is this a right way of approach as it also affects performance, or can we use the 2nd approach where we use one Extension for zone where it handles both lobby and game (with multiple modes).

2. Currently as we are using 3rd type of architecture, we had implemented the lobby in AS, and game server code in AS, and game client in Flash. the game talks across client and server properly. But, when we try to log in through the Lobby, create a room and open the client. The client couldn't log in as it gets the message "This username is already taken". how can we overcome this.

3. If, as you had suggested, we create one zone for the lobby, and one zone for the game, this is like changing from the 3rd type of architecture described in the doc. Even if we implement, how can we make the two talk between each other. It is mentioned in "Extension Interoperability" as

In the SmartFoxServer philosophy a ZONE is an "area" of the server where an application is running, and each "areas" should know nothing about the others. This approach leads to the most clean and less error-prone design possible, and we highly discourage to design any advanced multiplayer application basing on multiple Zones talking to each other.


So what way do you suggest that we should implement so that we have one lobby and many instances of the same game ( with various modes) where they can send data across easily and also that we can expand it for more games later (all created in Flash and AS).
-Sac
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 22 Dec 2009, 08:23

Questions:
1. Is this a right way of approach as it also affects performance, or can we use the 2nd approach where we use one Extension for zone where it handles both lobby and game (with multiple modes).

It is okay. Since SmartFox 1.6.2 we have largely improved the runtime compilation of AS extensions making the Room Level extension lighter and better performing.

2. Currently as we are using 3rd type of architecture, we had implemented the lobby in AS, and game server code in AS, and game client in Flash. the game talks across client and server properly. But, when we try to log in through the Lobby, create a room and open the client. The client couldn't log in as it gets the message "This username is already taken". how can we overcome this.

This is not clear. Are the games and Lobby in the same Zone?
Can you explain why you would need to connect twice?

A good idea can be to separate each game type in a different Zone, this is especially good if you plan to have many games each with lots of traffic. This way you won't mix game rooms and Users will be able to jump from one game Lobby to another very quickly.

An example:
- The client connects and receives a list of Zone names, suppose: chat, game1, game2, game3.
- The client is auto-joined in the "chat" Zone, a generic chatting Lobby where people can meet, edit their profile etc...
- The client can also choose to click on any other Lobby, to join it.
- When the user selects "game2" the client app performs a logout() and a login() in the new Zone, entering the specific game lobby. Here he will see al the game rooms, access the high score table, start new games, watch running games as spectator, move to another Lobby etc...

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
Sac_zeal
Posts: 5
Joined: 21 Dec 2009, 09:41

Postby Sac_zeal » 22 Dec 2009, 10:26

Hi Lapo,

Let me try and explain better this time :)

We are coming up with one game which has 3 different modes that a player can play it in. Each mode is slightly different from the other. The player when logs in, is taken to a list of games (in future, currently only one), on which player clicks a game, and enters into a lobby specific for that game. In this lobby the player can create a game or join a game with any mode, the lobby maintains all modes as long as it is the same game.

Now the lobby's front end is flash swf, and the game is also in flash swf. When the player clicks to create/join a game in the lobby client, a popup is open where the game is loaded. One of our requisite is that the player should be able to see the lobby and the game popup anytime the player wants.

Lobby extn is on the zone level and the game extn is on the room level.

Both are lobby and game are handled by different clients. The problem what we face is, when the player connects to the lobby, through the flash lobby client, and try to create a game (which pops up in a separate window), the game client is not able to log in as the server return's a message that the "This username is already taken".

Our problem is on how to over come this? or is there any better way to plan the design of what is needed to be achieved?

Hope i have explained it better this time, or else please let me know, i will try it again :)
-Sac
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 23 Dec 2009, 17:24

The popup should be internal to your the Flash Application and use the already existing connection object instead of creating a new SmartFoxClient and attempting to access the Zone with same User.
Lapo

--

gotoAndPlay()

...addicted to flash games
Sac_zeal
Posts: 5
Joined: 21 Dec 2009, 09:41

Postby Sac_zeal » 24 Dec 2009, 05:01

but both are different applications (lobby.swf and game.swf), can the connection be transferred ?

or are you telling exactly the same way how the examples do ? same swf with lobby in one frame and game in another? because this is not what our designers want, they want the game to open in a box apart from the lobby page.
-Sac
Sac_zeal
Posts: 5
Joined: 21 Dec 2009, 09:41

Postby Sac_zeal » 24 Dec 2009, 12:11

Thinking more into it, even if i open a flash app from another flash app, I was wondering how we can send the connection object from lobby.swf to game.swf
-Sac
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 26 Dec 2009, 18:23

Instead of using different browser windows I am suggesting to use different Flash windows. There is no need to use multiple frames as Flash and Flex already provide window components and can load external SWFs as modules.

This is a very common approach to modular applications, especially using Flex which is more component oriented.

Using multiple browser windows is not very convenient and will require more resources. For example 1000 players using 2 connections each will use 2000 sockets plus they will make it harder to coordinate and passing data around between the two modules.
Lapo

--

gotoAndPlay()

...addicted to flash games
Sac_zeal
Posts: 5
Joined: 21 Dec 2009, 09:41

Postby Sac_zeal » 20 Jan 2010, 05:46

HI Lapo,

Back to the same question, with a difference.

We are not using two flash swfs for Lobby and game client, instead we are going to use Java for Lobby and flash swf for game client.

If the player login in the Lobby, and then joins a game, the flash swf popup starts and here the flash client tries to login, and gets the same "This username is already taken".

How do we go about this problem when we are using Java lobby and flash swf based game client?
-Sac
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Jan 2010, 08:42

Unfortunately this is not possible in the same Zone.
A Zone only accepts a unique login from each client. The best solution is to keep the Lobby in one Zone and the Games in another one allowing the users to login from both Java and Flash.
Lapo

--

gotoAndPlay()

...addicted to flash games
noamgat
Posts: 10
Joined: 02 Dec 2009, 14:15

Postby noamgat » 20 Jan 2010, 08:54

Continuing this discussion, I indeed went with the two zone approach, as I suggested earlier and you recommended.

The question is - can these two zones interact with one another?
I'll explain the scenario :

The lobby zone is also the matchmaking zone. Lets say I have multiple games in my app, and the user is in the matchmaking room for game X.
He creates a room, another player joins, and they wish to start the game.

This means that the game zone needs to create a room for this game, adding the correct extensions to it. Is it possible for one zone to create a room in another zone with specific extensions? I could put this code in the client, but it makes much more sense for the server to manage this kind of action.

So, the flow I want is
1)User sends "Create game room" request from matchmaking zone
2)Server receives request, checks which game matchmaking room the user was in, creates appropriate room with appropriate extensions in game zone.
3)Server sends the name/pw of the gamezone room to the clients (still in the matchmaking zone)
4)Clients pass the room name/pw of the game zone room to the game app, which connects to the game zone, and the game starts.

The only part which I'm not sure SFS can do is the 2nd part. Is it possible?

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 37 guests