Dont get the LOGIN_ERROR

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Dont get the LOGIN_ERROR

Postby Robbilie » 02 Jul 2011, 11:37

hey guys

when i type in a wrong password or username my server throws a sfsloginexception but my client just receives this:


[SFS DEBUG] Error handling data: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
at System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
at System.String.Format (System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
at Sfs2X.Util.SFSErrorCodes.GetErrorMessage (Int32 code, System.Object[] args) [0x00000] in <filename unknown>:0
at Sfs2X.Controllers.SystemController.FnLogin (IMessage msg) [0x00000] in <filename unknown>:0
at Sfs2X.Controllers.SystemController.HandleMessage (IMessage message) [0x00000] in <filename unknown>:0
at Sfs2X.Core.SFSProtocolCodec.DispatchRequest (ISFSObject requestObject) [0x00000] in <filename unknown>:0
at Sfs2X.Core.SFSProtocolCodec.OnPacketRead (Sfs2X.Util.ByteArray packet) [0x00000] in <filename unknown>:0
at Sfs2X.Core.SFSIOHandler.HandlePacketData (Sfs2X.Util.ByteArray data) [0x00000] in <filename unknown>:0


can anybody help me?

its the default login:

public void OnLoginError(BaseEvent evt) {
Debug.Log("Login error: "+evt.Params["errorMessage"].ToString());
}

thanks ;)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 02 Jul 2011, 21:07

Definitely a bug - will look into it

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 05 Jul 2011, 14:10

any updates?
shanti
Posts: 45
Joined: 19 Jul 2011, 10:19

[SFS - error]

Postby shanti » 23 Jul 2011, 05:18

Robbilie wrote:any updates?


we are also getting semilar error. even though entered corret password.

[SFS - ERROR] Error handling data: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
at System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
at System.String.Format (System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
at Sfs2X.Util.SFSErrorCodes.GetErrorMessage (Int32 code, System.Object[] args) [0x00000] in <filename unknown>:0
at Sfs2X.Controllers.SystemController.FnLogin (IMessage msg) [0x00000] in <filename unknown>:0
at Sfs2X.Controllers.SystemController.HandleMessage (IMessage message) [0x00000] in <filename unknown>:0
at Sfs2X.Core.SFSProtocolCodec.DispatchRequest (ISFSObject requestObject) [0x00000] in <filename unknown>:0
at Sfs2X.Core.SFSProtocolCodec.OnPacketRead (Sfs2X.Util.ByteArray packet) [0x00000] in <filename unknown>:0
at Sfs2X.Core.SFSIOHandler.HandlePacketData (Sfs2X.Util.ByteArray data) [0x00000] in <filename unknown>:0


is their a fix for this..
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Aug 2011, 10:17

Might be that I inadvertently fixed this - but cant reproduce the error.

I'm doing this on the server as per tutorial:

Code: Select all

if (!verifyLogin(session, name, pwd)) {
        // Create the error code to send to the client
            SFSErrorData errData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_USERNAME);
            errData.addParameter(name);

   throw new SFSLoginException(errorMessage, errData);
}


And on the client side I get this:

Code: Select all

[SFS - INFO] Message: Login { Message id: 1 }
{ Dump: }

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

Login error: User name test is not recognized


from this code:

Code: Select all

         public void OnLoginError(BaseEvent e) {
            Console.WriteLine("Login error: "+(string)e.Params["errorMessage"]);
         }


This is with my latest SVN stuff - so as said can be that I fixed it earlier without realizing. Or its a rc3 fix.

If anyone wants to try this themselves, send me a pm and I can give you a SVN version compiled API

/T
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
LeMageFou
Posts: 18
Joined: 19 Aug 2011, 15:51

Postby LeMageFou » 19 Aug 2011, 16:06

Instead of that :

Code: Select all

public void OnLoginError(BaseEvent e) {
            Console.WriteLine("Login error: "+(string)e.Params["errorMessage"]);
         }

use this :

Code: Select all

public void OnLoginError (BaseEvent e)
{
Debug.Log(SFSErrorCodes.GetErrorMessage((int) evt.Params["errorCode"]));
}

And you'll have the error.


By the way, where is the SFSErrorCode enum in the C# API? I would like to do something like that :

Code: Select all

public void OnLoginError (BaseEvent e)
{
  SFSErrorCode code = (SFSErrorCode) evt.Params["errorCode"]);
  switch (code)
  {
    case LOGIN_BAD_PASSWORD :
    // Do something
    break;

    etc ..
  }
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 21 Aug 2011, 13:25

doesnt work for me...
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 22 Aug 2011, 19:21

LeMageFou wrote:Instead of that :

Code: Select all

public void OnLoginError(BaseEvent e) {
            Console.WriteLine("Login error: "+(string)e.Params["errorMessage"]);
         }

use this :

Code: Select all

public void OnLoginError (BaseEvent e)
{
Debug.Log(SFSErrorCodes.GetErrorMessage((int) evt.Params["errorCode"]));
}

And you'll have the error.


My code was from a unit test - and thus perfectly fine.

By the way, where is the SFSErrorCode enum in the C# API? I would like to do something like that :

Code: Select all

public void OnLoginError (BaseEvent e)
{
  SFSErrorCode code = (SFSErrorCode) evt.Params["errorCode"]);
  switch (code)
  {
    case LOGIN_BAD_PASSWORD :
    // Do something
    break;

    etc ..
  }


SFSErrorCode is not an enum unfortunately. Its a basic int sent by the server and then used by SFS2X.Util.SFSErrorCode static class via this static method public static string GetErrorMessage(int code, params object[] args) to return a readable message.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 22 Aug 2011, 19:23

Robbilie wrote:doesnt work for me...


As said - it might be something that was fixed by doing something else. Poke me with an email in a pm and you can get latest SVN dll to test if it works in your end or not with that.

I cant reproduce the error anyways here.

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
LeMageFou
Posts: 18
Joined: 19 Aug 2011, 15:51

Postby LeMageFou » 23 Aug 2011, 08:04

Thanks for the extra info Thomas.

I don't have the error anymore when I add server-side a parameter with the SFSErrorData for the SFSLoginException.
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 23 Aug 2011, 08:52

may u show what your servercode looks like so i can compare it to mine?

Because im currently not on pc...

Greetz
Robert
LeMageFou
Posts: 18
Joined: 19 Aug 2011, 15:51

Postby LeMageFou » 23 Aug 2011, 10:44

When the login fails, I throw a SFSLoginException like this :
SFSErrorData errorData = new SFSErrorData(SFSErrorCode.LOGIN_BAD_USERNAME);
errorData.addParameter("");
throw new SFSLoginException("", errorData);


If I remove the second line, I've got the error on the client side.
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 23 Aug 2011, 12:31

i have it done the same way but i dont have just "" i have smthng like "Username or password incorrect."

and as i said server gets the error in the logs but not the client...
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 26 Aug 2011, 12:49

hey guys look here !!!



Code: Select all

[SFS DEBUG] Error dispatching event loginError :Cannot cast from source type to destination type.   at LobbyGUI.OnLoginError (Sfs2X.Core.BaseEvent evt) [0x00000] in H:\Project\SFS2X FPS Tutorial\Unity FPS Client\SFS2XFPSTutorial\Assets\Lobby\Scripts\LobbyGUI.cs:298
  at Sfs2X.Core.EventDispatcher.DispatchEvent (Sfs2X.Core.BaseEvent evt) [0x00000] in <filename unknown>:0
UnityEngine.Debug:Log(Object)
LobbyGUI:OnDebugMessage(BaseEvent) (at Assets/Lobby/Scripts/LobbyGUI.cs:320)
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.Logging.Logger:DispatchEvent(LoggerEvent)
Sfs2X.Logging.Logger:Log(LogLevel, String)
Sfs2X.Logging.Logger:Error(String[])
Sfs2X.Core.EventDispatcher:DispatchEvent(BaseEvent)
Sfs2X.SmartFox:ProcessEvents()
LobbyGUI:FixedUpdate() (at Assets/Lobby/Scripts/LobbyGUI.cs:242)


different error and OnLoginError is mentioned :DDDD
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 26 Aug 2011, 12:54

yaaaaaaay :D

i used the wrong code from LeMageFou and with thomas code all works fine :)))))

thanks thomas your neew dll works :D

but the uservar problem still exists...

other subject other thread :D

Greetz
Robert

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 40 guests