LOGIN_OUT_DATA equivalent for unsuccessful login?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 08 Oct 2012, 17:19

Hey guys,

I'm sure I'm missing (again!) some doc page... I see that LOGIN_OUT_DATA is available only when the login is successful: is there any equivalent way to send data to the client upon unsuccessful login?

Thanks,
Pino
Cheers!
Pino
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby Lapo » 09 Oct 2012, 08:18

No, you can send a custom error if you want, but no objects.
Of course your error string can be formatted as you please so you can later extract parameters from it, if necessary.

For the details on custom errors, check this post:
viewtopic.php?f=18&t=14390
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 09 Oct 2012, 09:27

Hi,

I did try that but it generates an "index out of bound" error on the client (Unity, so it's C#) and the method stops processing because of that :/
Cheers!
Pino
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby Lapo » 09 Oct 2012, 10:33

I think you're using a pretty old API, please get the latest update.
http://www.smartfoxserver.com/download/sfs2x#p=updates
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 09 Oct 2012, 15:19

Lapo wrote:I think you're using a pretty old API, please get the latest update.
http://www.smartfoxserver.com/download/sfs2x#p=updates


Hi Lapo,

downloaded the current DLL you pointed me to, but the result is unchanged, running on iOS6 (iPad2) this is what I get in the XCode tracing panel:

[SFS DEBUG] Formatting error string failed with exception: Array index is out of range

Am I missing something?
Cheers!
Pino
User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 09 Oct 2012, 15:22

Wait... maybe I did miss something else ... I'll double check.
Cheers!
Pino
User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 09 Oct 2012, 15:51

Ok, no, checked everything and I still have:

[SFS - DEBUG] <<< Packet Complete >>>
[SFS - INFO] Message: Login { Message id: 1 }
{ Dump: }

(short) ec: 200
(utf_string_array) ep: [System.String[]]

[SFS - ERROR] Formatting error string failed with exception: Array index is out of range.
Cheers!
Pino
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby Lapo » 09 Oct 2012, 16:08

It looks like there's a mismatch with the parameters in the String.
Can you please show me what's being sent from the server side?
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 09 Oct 2012, 16:40

Sure,

On te server side:

Declaration:

Code: Select all

public enum BionautsErrors implements IErrorCode {
   WE_NEED_LINKING_PROFILE(200),
   BAD_LINKING_USERNAME(201),
   BAD_LINKING_PASSWORD(202),
   USERNAME_IN_USE(203);

   private short id;
   
   private BionautsErrors(int id)
   {
      this.id = (short) id;
   }

   @Override
   public short getId() {
      // TODO Auto-generated method stub
      return id;
   }
}


Code usage in the login handler (the initial test):

Code: Select all

              if (!linkNow && !createNow)
              {
                 // Build a prepared statement
                 stmt = connection.prepareStatement(FBDB_SELECT);
                 stmt.setString(1, FBemail);
                
                 // Execute query
               res = stmt.executeQuery();
   
                 if (!res.first()) // User has no account with Facebook email
                 {
                  // This is the part that goes to the client
                  SFSErrorData errData = new SFSErrorData(BionautsErrors.WE_NEED_LINKING_PROFILE);
                  
                  connection.close();
                  trace("FB Login Error: no user");
                  throw new SFSLoginException("FB Login Error: no user", errData);
                 }
            // Successful FB SSO login
                 outData.putUtfString(SFSConstants.NEW_LOGIN_NAME, res.getString("usernameusers"));
              }


On the client, after the SFS initialization I have:

Code: Select all

SFSErrorCodes.SetErrorMessage (200, "User not found, Link or Create?");
SFSErrorCodes.SetErrorMessage (201, "User {0} not found!");
SFSErrorCodes.SetErrorMessage (202, "Wrong Pass for {0}!");
SFSErrorCodes.SetErrorMessage (203, "{0} is taken!");
Cheers!
Pino
User avatar
DFTGames
Posts: 30
Joined: 30 Mar 2012, 00:48
Location: Ireland
Contact:

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby DFTGames » 09 Oct 2012, 18:11

I just tried adding a fake paramenter to that error code 200... just in case the paramenter was mandatory, but nothing changes :/ In the meanwhile (while you study the issue) I'm going back adding the code as a paramenter to one of the standard error messages and checking the received message to see if it contains that code... not efficient but it works ;)
Cheers!
Pino
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby Lapo » 09 Oct 2012, 19:13

Ok, I have asked ThomasLund to take a look, he knows the C# API much better than me :)
Lapo

--

gotoAndPlay()

...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Re: LOGIN_OUT_DATA equivalent for unsuccessful login?

Postby ThomasLund » 04 Nov 2012, 17:27

The C# API is using a string[] to store error messages in. I changed that to now use a List<string> instead.

If you hit me up with a PM with your email, I can send you a SVN build so we can test this and make certain it works as you expect it.

/T
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 107 guests