Page 1 of 1
custom login userID
Posted: 27 Sep 2010, 16:23
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 ?
Posted: 27 Sep 2010, 17:33
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.
Posted: 27 Sep 2010, 20:23
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.
Posted: 27 Sep 2010, 20:32
by BigFIsh
Yes - you can send userId/userName along with login status command (i.e. logOK) via sendResponse from your zone extension.
Posted: 27 Sep 2010, 20:48
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.
Posted: 27 Sep 2010, 22:03
by BigFIsh
It's u.getUserId()
Please refer to this API documentation -->
http://www.smartfoxserver.com/docs/docP ... /index.htm.
Posted: 28 Sep 2010, 12:31
by appels
Thanks BigFish, all is working now.