Page 1 of 1
- (void)onLogin don't get called after login
Posted: 30 Sep 2009, 15:27
by aw2xcd
Code: Select all
INFSmartFoxExtHandler:handleMessage msgObj:<msg t='xt'><body action='xtRes' r='-1'><![CDATA[<dataObj><var n='_cmd' t='s'>OK</var></dataObj>]]></body></msg>
I get this back when I run login but onLogin don't get called.
Any ideas?
Posted: 08 Nov 2009, 11:51
by MrMooMoo
I too get the same problem. If I log into a Zone with the default login then the onLogin event callback gets called. As soon as I create my own custom login (using the sample code) I get no event callback.
Any ideas? I guess I can use the ExtensionResponse callback for now but not ideal.
Ta,
Moo.
Posted: 08 Nov 2009, 15:06
by MrMooMoo
Ok, from reading more of the documentation and several forum posts, it looks like the onLogin event callback doesn't get called if you're creating your own extension.
Instead you need to use the ExtensionResponse callback. I've implemented this and it appears to work fine.
Posted: 09 Nov 2009, 09:24
by Lapo
Yes, this is correct.
With Zone attribute
customLogin set to
true you will be responsible for sending the login response back to the client.
In the response you will need to at least send the user Id that should be assigned to the local API userId property. You can also add any other custom data that is relevant to your application logic.
You can take a look at the Custom Login tutorial for Flash here:
http://www.smartfoxserver.com/docs/docP ... /index.htm
Although the client part might be slightly different, the server side is the same for any client technology.
Posted: 09 Nov 2009, 21:10
by MrMooMoo
Lapo wrote:Yes, this is correct.
With Zone attribute
customLogin set to
true you will be responsible for sending the login response back to the client.
In the response you will need to at least send the user Id that should be assigned to the local API userId property. You can also add any other custom data that is relevant to your application logic.
You can take a look at the Custom Login tutorial for Flash here:
http://www.smartfoxserver.com/docs/docP ... /index.htm
Although the client part might be slightly different, the server side is the same for any client technology.
Thanks, Lapo. I thought that was the case and have implemented this exact solution. One question though, you mention that you need to send back the userID which is then assigned to the local API. I'm not too sure what you mean by this and cannot see where it's done in the example. I guess I've not needed to use this variable just yet but if you could give me some pointers on where it's used (particular API class, etc.) that would be great.
Ta,
Moo.
Posted: 12 Nov 2009, 10:04
by Lapo
You are right, it's not mandatory to set the myUserId but I think it is recommendable.
This is from the onLogin doc for Actionscript 3
NOTE 2: for SmartFoxServer PRO. If the Zone you are accessing uses a custom login the login-response will be sent from server side and you will need to handle it using the onExtensionResponse handler.
Additionally you will need to manually set the myUserId and myUserName properties if you need them. (This is automagically done by the API when using a default login)
If this is missing in Objective-C we will add it in the next release.
Posted: 12 Nov 2009, 11:14
by Lapo
Posted: 12 Nov 2009, 19:14
by MrMooMoo
Thanks for the clarification. The only question I have remaining is how you get hold of the relevant myUserID to set on the client side. I'm guessing I need to send it back to the client from my customised extension. If so, where do I get the userID from within the extension or is it something I simply create myself and it's my responsibility to make sure it's unique.
Thanks for the help.
Posted: 13 Nov 2009, 09:04
by Lapo
The ID is assigned to the User object automatically by the server, so its just a matter of calling User.getUserId() and that's all.
Optionally you can add some other custom data if it's needed on the client side.
Posted: 16 Nov 2009, 19:28
by MrMooMoo
Lapo wrote:The ID is assigned to the User object automatically by the server, so its just a matter of calling User.getUserId() and that's all.
Optionally you can add some other custom data if it's needed on the client side.
Excellent. That should cover it. Thanks for help.