- (void)onLogin don't get called after login

Post here all your questions related with the SmartFoxServer iPhone API

Moderators: Lapo, Bax

aw2xcd
Posts: 6
Joined: 28 Sep 2009, 18:20

- (void)onLogin don't get called after login

Postby aw2xcd » 30 Sep 2009, 15:27

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?
MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Postby MrMooMoo » 08 Nov 2009, 11:51

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.
MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Postby MrMooMoo » 08 Nov 2009, 15:06

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.
User avatar
Lapo
Site Admin
Posts: 20437
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 09 Nov 2009, 09:24

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.
Lapo
--
gotoAndPlay()
...addicted to flash games
MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Postby MrMooMoo » 09 Nov 2009, 21:10

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.
User avatar
Lapo
Site Admin
Posts: 20437
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Nov 2009, 10:04

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

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 20437
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Nov 2009, 11:14

By the way both login tutorials explain the myUserId matter:
http://www.smartfoxserver.com/docs/docP ... _loginExt/
http://www.smartfoxserver.com/docs/docP ... /index.htm

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Postby MrMooMoo » 12 Nov 2009, 19:14

Lapo wrote:By the way both login tutorials explain the myUserId matter:
http://www.smartfoxserver.com/docs/docP ... _loginExt/
http://www.smartfoxserver.com/docs/docP ... /index.htm

hope it helps


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.
User avatar
Lapo
Site Admin
Posts: 20437
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 13 Nov 2009, 09:04

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

--

gotoAndPlay()

...addicted to flash games
MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Postby MrMooMoo » 16 Nov 2009, 19:28

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.

Return to “iPhone Objective-C API”

Who is online

Users browsing this forum: No registered users and 1 guest