RoomVariables. Error when trying to delete

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

vinnie.vivace
Posts: 4
Joined: 12 Mar 2009, 19:47
Location: new zealand
Contact:

RoomVariables. Error when trying to delete

Postby vinnie.vivace » 27 Jul 2010, 00:35

as per the API documentation i am using the following to try and delete a room variable:

Code: Select all

public void removeRoomVariable(string name)
{
        ArrayList rVars = new ArrayList();
        rVars.Add(new RoomVariable(name, null));

        this._smartFox.SetRoomVariables(rVars);
}


however i receive the following error:

NullReferenceException: Object reference not set to an instance of an object
SmartFoxClientAPI.SmartFoxClient.GetXmlRoomVariable (SmartFoxClientAPI.Data.RoomVariable rVar)


The supplied room variable definetly exists as is shown in the admin tool.

Any help would be greatly appreciated.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Jul 2010, 06:12

I'm compiling a list of bug reports right now (today and tomorrow) on the current SFS1 API, and will add this one to the list.

/Thomas
vinnie.vivace
Posts: 4
Joined: 12 Mar 2009, 19:47
Location: new zealand
Contact:

Postby vinnie.vivace » 27 Jul 2010, 21:18

Thanks Thomas... any idea what sort of timeframe we are talking to get this addressed?

Cheers
Vinnie
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Jul 2010, 07:49

Will start to take a look at things during the weekend most likely (depends on weather + how much my wife wants me to help paint the house) :-)

Doesnt mean I get it fixed this weekend - but I'll take a look at all the issues reported and verify them as minimum.

Its summer vacation, so things go slow + SFS2X has priority over bugfixes.

/Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 28 Jul 2010, 07:52

There is always the possibility of someone helping (I'm working on a volunteer basis BTW on this!!).

The sources are available in the regular API download, so things like this should be pretty easy to find yourself + fix. And if you share the fix, it will help me a lot.

/Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 01 Aug 2010, 10:23

Bug fixed - in case you want it right now and not wait for the API update, then this is the new method in SmartFoxClient.cs

Replace the old one around line 2750'ish

Code: Select all

      private string GetXmlRoomVariable(RoomVariable rVar) {
         // Get properties for this var
         string vName = rVar.GetName();
         object vValue = rVar.GetValue();
         string vPrivate = ( rVar.IsPrivate() ) ? "1" : "0";
         string vPersistent = ( rVar.IsPersistent() ) ? "1" : "0";

         string t = null;

         // Check type
         if ( vValue == null ) {
            t = "x";
            vValue = "";
         } else if ( vValue.GetType() == typeof(bool) ) {
            t = "b";
            vValue = ( (bool)vValue ) ? "1" : "0";         // transform in number before packing in xml
         } else if ( vValue.GetType() == typeof(int) ) {
            t = "n";
         } else if ( vValue.GetType() == typeof(string) ) {
            t = "s";
         }

         if ( t != null )
            return "<var n='" + vName + "' t='" + t + "' pr='" + vPrivate + "' pe='" + vPersistent + "'><![CDATA[" + vValue + "]]></var>";
         else
            return "";
      }

vinnie.vivace
Posts: 4
Joined: 12 Mar 2009, 19:47
Location: new zealand
Contact:

Postby vinnie.vivace » 04 Aug 2010, 21:00

oh dude, legend!
apologies for the slow response. I read your comments and fully related, young family of my own. So had intended to do exactly as you suggested and fix myself, but hey, thanks dude.
vinnie.vivace
Posts: 4
Joined: 12 Mar 2009, 19:47
Location: new zealand
Contact:

Postby vinnie.vivace » 04 Aug 2010, 21:07

yep, working sweet. thanks again.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Aug 2010, 05:41

Happy it works - will be rolled into an update asap.
flashbk
Posts: 16
Joined: 08 Jul 2010, 05:45

GetXmlUserVariable has same error

Postby flashbk » 10 Aug 2010, 08:20

GetXmlUserVariable has same error
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 10 Aug 2010, 11:37

Duh - I should have looked. Will fix tonight!

Thanks for reporting

/Thomas
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 13 Aug 2010, 12:01

Fixed - same fix as the other one (different variable name, but else same same).

All known bugs done - wrapping it for a 1.2.6 release

/Thomas

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 24 guests