Session Removal when restarting with Unity.

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

storm72
Posts: 3
Joined: 18 Sep 2018, 00:13

Session Removal when restarting with Unity.

Postby storm72 » 18 Sep 2018, 00:47

Hello,

I have a strange session removal occurring with Unity that maybe someone could help solve.

One of my games modes is a single player against AI which has all the game logic running on the server. If the only user then quits the game (user has fully disconnected) I would like to have the ability to automatically rejoin the player against the AI if he relaunches the game
and rejoins the room within 60 seconds.

Currently, if I stop the game running in the Unity Editor, I can see the game logic is still running on the server as it should, great! However, as soon as I hit the play button in Unity to emulate a user coming back in, the server removes the session ->

11:14:04,562 INFO [SocketReader] sessions.DefaultSessionManager - Session removed: { Id: 4, Type: DEFAULT, Logged: Yes, IP: 127.0.0.1:63913 }

When this occurs, the game in Unity hasn't even launched (takes a few seconds to launch the game as it is so large) and it hasn't reached the SFS Initialization code or login code.

My session maximum idle time is set to 60, with user maximum idle time set to 500, and SFS is running on my local host.

I'm sure I must be doing something wrong, any help would be appreciated.

Thanks.

SFS Version 2.13.0
Unity Version 2018.2.0f2
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Session Removal when restarting with Unity.

Postby Lapo » 18 Sep 2018, 07:46

Hi,
there're a couple of things that are not very clear.

storm72 wrote:Hello,
Currently, if I stop the game running in the Unity Editor, I can see the game logic is still running on the server as it should, great! However, as soon as I hit the play button in Unity to emulate a user coming back in, the server removes the session ->

If you have stopped the game then your previous connection has been shut down.
Then you say that you "hit the play button to emulate a user coming back"... By pushing play you're just starting a new client, which will start from scratch by connecting, then logging in etc...

Maybe it's just an issue with wording, but typically we refer to "re-connecting" as an attempt to connect again when an unexpected disconnection has occurred within the same game session.

In this case it sounds like you've shut down the game and the started a new one from scratch. Is this correct or am I missing something else?
Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
storm72
Posts: 3
Joined: 18 Sep 2018, 00:13

Re: Session Removal when restarting with Unity.

Postby storm72 » 18 Sep 2018, 10:00

Hi Lapo,

Thanks for your response. I'll try to clear up what I'm doing and the problem.

1) 'NEW CLIENT' - I start the game in the Unity editor, after the scene loads which takes approx. 5 seconds, then the connection & login code executes.

2) I then select the single player vs. AI option. Game room 'A' is created and the user joins this room. The room extension starts executing as expected.

3) Now I want to emulate a mobile crash or an app close - so I hit the 'stop' button in Unity. At this stage, the room stays active for at least 60 seconds to give the player a chance to reconnect and continue from where he left off.

4) To reconnect and continue, I start the game again in Unity. However, the instant I hit run in Unity, the session is removed on the server. This removal occurs before the scene even loads, meaning the connection & logging in logic hasn't executed.

At this stage, it is irrelevant if I'm starting a new client or not. The previous session should not be removed at any stage until the 'user maximum idle time' has elapsed.

What is even stranger is that if I view step #4 from above while using the web-admin zone monitor, the session does not get removed until the 'user maximum idle time' elapses. (the expected behavior).

Thanks,
Paul.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Session Removal when restarting with Unity.

Postby Lapo » 18 Sep 2018, 10:15

Hi,
thanks for info. On more clarification:
storm72 wrote:4) To reconnect and continue, I start the game again in Unity. However, the instant I hit run in Unity, the session is removed on the server.

You mean the old connection from the first run?
Or the new connection?
I ask because you said it takes approx. 5 seconds for the level to load before the client connects. Here instead you're saying that a connection is being shut down "the instant you hit run in Unity".

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
storm72
Posts: 3
Joined: 18 Sep 2018, 00:13

Re: Session Removal when restarting with Unity.

Postby storm72 » 18 Sep 2018, 17:05

You mean the old connection from the first run?


To be clear, the issue that I'm experiencing is that old room session is getting removed incorrectly. I understand the first sfs connection ends once I stop running in Unity in step #3, however, the room session should stay alive for 60 seconds (or whatever the user idle time is set to).

Here is step #4 I'm experiencing in a little more granularity.

4.
a) I start the game again in Unity.
b) Old 'room session' is removed instantly.
c) Scene loads (takes approx. 5 seconds).
d) A new connection is established. (once the scene load completes)
e) User can't rejoin the room session to continue playing as it has been removed.

Desired step 4.

4.
a) I start the game again Unity.
b) Scene loads (takes approx. 5 seconds).
c) A new connection is established. (once the scene load completes)
d) From data-store (Firebase) I now recognize that the user bailed on an active room session. (that is still running on the server)
e) User is then placed into the old 'room session' automatically which is alive for 60 seconds.
f) The user now continues to play the game against AI where he left off.

Thanks for your help on this.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Session Removal when restarting with Unity.

Postby Lapo » 19 Sep 2018, 07:59

To be clear, the issue that I'm experiencing is that old room session is getting removed incorrectly. I understand the first sfs connection ends once I stop running in Unity in step #3, however, the room session should stay alive for 60 seconds (or whatever the user idle time is set to).

There is no such thing as a "Room session" in SmartFoxServer. A Session represents the period of time between a user's login and relative logout.

There is no other type of Session in SmartFoxServer, so I am really not sure what you're referring to when you say "Room session".

Also there's a misunderstanding on the user idle timer parameter (which is a Zone parameter).
This value tells the server how long a connected user can remain idle (not sending any requests) before the server auto-disconnects him/her.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 137 guests