Is it possible to check if user already logged in?

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

crosskid
Posts: 36
Joined: 30 Oct 2012, 07:56

Is it possible to check if user already logged in?

Postby crosskid » 21 Feb 2013, 11:02

Hello, as a subject, is there any way to check from client if he already logged into smartfox or not?
well, as far as i know there is just checking connection to smartfox with something like

Code: Select all

[_smartfox isConnected]
or

Code: Select all

_smartfox.isConnected

thanks
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Re: Is it possible to check if user already logged in?

Postby A51Integrated » 21 Feb 2013, 17:55

You can achieve that in a number of ways. After login (not connection), the client will be assigned a SFS id and have a user object created. So one can always use

Code: Select all

[client mySelf]

and see if that is a valid user (http://docs2x.smartfoxserver.com/api-do ... ame/mySelf).

Similarly, you can use the room object as apposed to the user and check the lastJoinedRoom (http://docs2x.smartfoxserver.com/api-do ... JoinedRoom).

In combination with isConnected, you should then be able to tell if a user is logged in.
A51 Integrated
http://a51integrated.com / +1 416-703-2300
crosskid
Posts: 36
Joined: 30 Oct 2012, 07:56

Re: Is it possible to check if user already logged in?

Postby crosskid » 22 Feb 2013, 03:17

thanks, that will do the trick :D

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 16 guests