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.
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.
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.
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.
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.
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.
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.
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.
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.