Unity - How to detect DISCONNECT from client

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

xogamedev
Posts: 1
Joined: 08 Dec 2014, 09:55

Unity - How to detect DISCONNECT from client

Postby xogamedev » 29 Jan 2018, 11:23

Hi :)
I got a problem:
1- I want to detect when user kill app(ios, android, window pc...) or lost internet from client, how could I got this event.
2- When 2 users in the same room, when an user disconnect(by case 1), how could I know, it doesn't fire event USER_EXIT.
Please help me :)
Thank you very much
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Unity - How to detect DISCONNECT from client

Postby Lapo » 29 Jan 2018, 15:34

Hello,
1- I want to detect when user kill app(ios, android, window pc...) or lost internet from client, how could I got this event.

There is an event in Unity that tells you when the app quits:
https://docs.unity3d.com/ScriptReferenc ... nQuit.html

As regards when the app looses connection, there's an SFS2X client event called SFSEvent.CONNECTION_LOST.
If you're not familiar with this I highly recommend to take a look at this very simple Unity example:
http://docs2x.smartfoxserver.com/Exampl ... /connector

2- When 2 users in the same room, when an user disconnect(by case 1), how could I know, it doesn't fire event USER_EXIT.

There is no USER_EXIT event.
There is an event called SFSEvent.USER_EXIT_ROOM which signals when a user has left the Room (if you and the user were joined in the same Room)

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 26 guests