custom login userID

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

Moderators: Lapo, Bax

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

custom login userID

Post by appels »

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 ?
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

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:

Post by appels »

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.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

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:

Post by appels »

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.
BigFIsh
Posts: 1698
Joined: 25 Feb 2008, 19:26
Location: New Zealand

Post by BigFIsh »

It's u.getUserId()

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

Post by appels »

Thanks BigFish, all is working now.
Post Reply