Search Unity

SmartFox custom login data back to Unity

Discussion in 'Multiplayer' started by appels, Sep 28, 2010.

  1. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    Hi,

    I'm trying to read data that comes back from a custom login extension in SFS.
    Normally i would use :
    Code (csharp):
    1. responseData.GetString("myInt")
    to fetch the string but in my case i need to catch an integer.
    What do i have to use to fetch the int ?
    GetInt doesn't exist...

    If I use :
    Code (csharp):
    1. responseData.GetString("myInt")
    I get an exception error :

    Code (csharp):
    1. [SFS DEBUG] ERROR: Exception thrown dispatching event. Exception: System.InvalidCastException: Cannot cast from source type to destination type.
    2.   at SmartFoxClientAPI.Data.SFSObject.GetString (System.Object key) [0x00000] in <filename unknown>:0
    Anyone ?
     
  2. cadamson

    cadamson

    Joined:
    Oct 11, 2009
    Posts:
    27
    If you are needing to convert a string passed back from SFS to an integer you could use:
    Code (csharp):
    1. int.Parse(responseData.GetString("myInt")
    If you are getting a number back from SFS:
    Code (csharp):
    1. (int)responseData.GetNumber("myInt")
    Chad
     
  3. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    yeah, i managed to get it with : smartFox.myUserId = Convert.ToInt32(responseData.Get("myID"));