custom login userID

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

custom login userID

Postby appels » 27 Sep 2010, 16:23

Hi,

I read that i need to assign the userID to the client after login when using the custom login extension.
Can i send the userID through my extension response or do i have to make the client pull it from the server ?
I can't find it in the server docs.
Any tips ?
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 27 Sep 2010, 17:33

Each users comes with a userId and userName. You can confirm this by analyzing the incoming messages from the server.

You set the userId/userName like this:

smartFox.myUserId = thatUserId
smartFox.myUserName = thatUserId

where smartFox is your SmartFoxClient instance.
Smartfox's forum is my daily newspaper.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 27 Sep 2010, 20:23

yes but that won't work for me. I need to get the ID through my extension if possible but i can't seem to get it there.
Is it possible ? So i can send the id to the client.
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 27 Sep 2010, 20:32

Yes - you can send userId/userName along with login status command (i.e. logOK) via sendResponse from your zone extension.
Smartfox's forum is my daily newspaper.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 27 Sep 2010, 20:48

ok but how can i get the userId in the extension ?
i just tried :

in the handlerequest :
var u = _server.instance.getUserByChannel(chan)
newUser = u.getId();
in the handleInternalEvent :
response.myID=newUser;

but that gave me and undefined.
User avatar
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Postby BigFIsh » 27 Sep 2010, 22:03

It's u.getUserId()

Please refer to this API documentation --> http://www.smartfoxserver.com/docs/docPages/serverSideApi/index.htm.
Smartfox's forum is my daily newspaper.
appels
Posts: 464
Joined: 28 Jul 2010, 02:12
Contact:

Postby appels » 28 Sep 2010, 12:31

Thanks BigFish, all is working now.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 11 guests