How could i get the error code from the event onLoginError

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

scofy
Posts: 79
Joined: 08 Apr 2012, 09:04

How could i get the error code from the event onLoginError

Postby scofy » 24 Jun 2012, 13:01

Handling Message: Login: { Message id: 1 }
{Dump: }

(short) ec: 28
(utf_string_array) ep: [(
"userName has badword"
)]
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Re: How could i get the error code from the event onLoginErr

Postby A51Integrated » 25 Jun 2012, 12:32

Have a look at the docs: http://docs2x.smartfoxserver.com/api-do ... LoginError:

Code: Select all

-(void)onLoginError:(SFSEvent *)evt
 {
     NSLog(@"Login Failed. Reason: %@" ,[evt.params objectForKey:@"errorMessage"]);
 }


An easy way to loop through the entire response object (for any event) would be:

Code: Select all

-(void)onLoginError:(SFSEvent *)evt
{
   NSArray *keys = [evt.params allKeys];
   
   for (NSString *key in keys)
    {
      NSLog(@"%@: %@", key, [evt.params objectForKey:key]);
   }
}
A51 Integrated
http://a51integrated.com / +1 416-703-2300
scofy
Posts: 79
Joined: 08 Apr 2012, 09:04

Re: How could i get the error code from the event onLoginErr

Postby scofy » 28 Jun 2012, 03:46

There was not a key of "errorCode",I just see a key name "success" and it's value always "0".
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Re: How could i get the error code from the event onLoginErr

Postby A51Integrated » 28 Jun 2012, 10:25

Please make sure you're using the latest server patch and the latest iOS API:
http://www.smartfoxserver.com/download/sfs2x#p=updates

If you post some code, maybe we can have a look and see if there is something you're doing wrong.
A51 Integrated

http://a51integrated.com / +1 416-703-2300
albert
Posts: 2
Joined: 21 Jul 2012, 03:22

Re: How could i get the error code from the event onLoginErr

Postby albert » 21 Jul 2012, 03:37

I have the same problem.
No matter what I do it not work.even in my own errocode

server1:
SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_PASSWORD);
errData.addParameter(userName);
throw new SFSLoginException("Error", errData);
server2:
SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_USERNAME);
errData.addParameter(userName);
throw new SFSLoginException("Error", errData);

server3:
SFSErrorData ed = new SFSErrorData(MyCustomErrors.USER_IS_CREATED);
ed.addParameter(userName);
throw new SFSLoginException("Right, user created", ed);

server3:
SFSErrorData ed = new SFSErrorData(MyCustomErrors.USER_IS_EXISTED);
ed.addParameter(userName);
throw new SFSLoginException("Wrong, user is existed", ed);


client:
private void onLoginError(BaseEvent evt){
Debug.Log("Login error (" + evt.Params["errorCode"] + "): " + evt.Params["errorMessage"]);
}


get: (always the same)
Login error (28): An unexpected error occurred, please check the server side logs
User avatar
A51Integrated
Posts: 240
Joined: 03 Jan 2012, 19:55
Location: Toronto, Canada
Contact:

Re: How could i get the error code from the event onLoginErr

Postby A51Integrated » 21 Jul 2012, 14:24

I'm not sure what you're trying to do here. What do the server logs say? Also, make sure you're posting your question to the right forum - this is for Objective-C / iOS API.
A51 Integrated

http://a51integrated.com / +1 416-703-2300
albert
Posts: 2
Joined: 21 Jul 2012, 03:22

Re: How could i get the error code from the event onLoginErr

Postby albert » 22 Jul 2012, 05:51

Thanks for your reply.
I have solved this problem

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 48 guests