Problem: OnRoomAdded is not fired

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

Moderators: Lapo, Bax

User avatar
Real McCoy
Posts: 21
Joined: 06 Dec 2008, 12:01

Problem: OnRoomAdded is not fired

Postby Real McCoy » 15 Mar 2009, 05:09

Hello!

SFS .NET 1.1 installed.

The problem occurs in following situation:
- User1 is connected and joined to room "Heli Attack 3".
- User2 is connected and joined to room "Heli Attack 3".
- User2 trying to create room "Spore Attack". Room is created but OnRoomAdded event is not fired.

Debug info:

Code: Select all

SFC debug message: "[Sending]: <msg t='sys'><body action='createRoom' r='204'><room tmp='1' gam='1' spec='0' exit='1'><name><![CDATA[Spore Attack]]></name><pwd><![CDATA[]]></pwd><max>20</max><vars></vars></room></body></msg>
"
SFC debug message: "[ RECEIVED ]: <msg t='sys'><body action='joinOK' r='5'><pid id='1'/><vars /><uLs r='5'><u i='1' m='0' s='0' p='1'><n><![CDATA[User2]]></n><vars></vars></u></uLs></body></msg>, (len: 160)"
SFC debug message: "XML Handler null reference exception System.NullReferenceException: Object reference not set to an instance of an object.
   at SmartFoxClientAPI.Handlers.SysHandler.HandleJoinOk(XmlNode xml)
   at SmartFoxClientAPI.Handlers.SysHandler.HandleMessage(Object msgObj, String type)
   at SmartFoxClientAPI.SmartFoxClient.XmlReceived(String msg)"


In other situations event fires properly.

BTW, one more strange in described situation: in the code I call only

Code: Select all

sfc.CreateRoom(paramsHash, roomId);
no join room (it could be called in OnRoomAdded handler), but server log shows "newRoom" and "userJoin" events from User2.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 15 Mar 2009, 08:38

Hi!

Definitely sounds like some funky bug - can you cut'n'paste the code where you create the room (so I can see what variables you use).

A create room will automagically join you if its a game room (as per documentation). So thats why you see the userjoin.

Best
Thomas
User avatar
Real McCoy
Posts: 21
Joined: 06 Dec 2008, 12:01

Postby Real McCoy » 15 Mar 2009, 12:46

There is a code for creating room:

Code: Select all

SFSEvent.onRoomAdded += OnRoomAddedHandler;
// ...
roomName = "Spore Attack";
roomId = 204;
// ...
Hashtable roomParams = new Hashtable();
roomParams.Add("name", roomName);
roomParams.Add("isGame", true);
roomParams.Add("maxUsers", 20);
sfc.CreateRoom(roomParams, roomId);

Add room handler:

Code: Select all

private void OnRoomAddedHandler(Room room)
{
    sfc.JoinRoom(room);
}
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 17 Mar 2009, 13:19

Hi - sorry for the delay in responding.

Very weird. I cannot reproduce your error. I do the exact same thing - copy/paste of your code, and my onRoomAdded is called.

No error or exception.

My SFS client _is_ slightly modified (running on trunk), so I will recheck with 1.1. But none of the changes should have an impact.

Besides that, I am running on latest SFS pro pathced up to most recent patch level.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 27 guests