ExtensionDescriptor in SmartFoxClientAPI.NewRoomDescriptor

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

Moderators: Lapo, Bax

DziD
Posts: 4
Joined: 20 Jul 2010, 11:41

ExtensionDescriptor in SmartFoxClientAPI.NewRoomDescriptor

Postby DziD » 20 Jul 2010, 11:47

Hi all!

I want to create a room from script, it's work fine, but how I could set extension to created room?

In config file extension in my created room like this:
<extension name="json" className="MyRoom.as" type="script" />

Extension places in a server side.

I'am find ExtensionDescriptor, but I don't understand what mean parameters in constructor: ExtensionDescriptor(string name, string script)

What's mean script, it's mean a file name?? or text/listing of script
What's mean name, json java etc? or I wrong?

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

Postby Lapo » 21 Jul 2010, 12:25

Hi,
take a look at the provided SmartFoxTris example that you find with the API. It shows exactly what you are looking for. In particular I am referring to the LobbyGUI.cs file, lines 126-140.

Code: Select all

...
Hashtable ext = new Hashtable();
ext.Add("name", "tris");
ext.Add("script", "sfsTris.as");

roomObj.Add("extension", ext);

smartFox.CreateRoom(roomObj);
...

name is the name you will assign to the extension, used to refer to it from client
script is the name of the script file name (Actionscript/Python) or the fully qualified Java class name (for Java extensions)
Lapo
--
gotoAndPlay()
...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 22 Jul 2010, 13:22

There is also the option to use the extension descriptor. This is done similar to this:

Code: Select all

NewRoomDescriptor roomObj = new NewRoomDescriptor (roomName, numMaxUsers, true, 0, new ArrayList (), new NewRoomDescriptor.ExtensionDescriptor ("fpsExtension", "dk.fullcontrol.fpsdemo.FpsExtension"), "", true, true);

smartFox.CreateRoom (roomObj);
DziD
Posts: 4
Joined: 20 Jul 2010, 11:41

Postby DziD » 26 Jul 2010, 14:08

Thanks!
Ok room creates now, but when I trying connect to it (on remote machine) I have fail, and when I try getActiveRoom method then I also have fail.

Maybe you know whats the problem?

I.E. On Client Side room likes created but it not yet... why? I don't know :(

my code C#:

Code: Select all

                    Hashtable newRoom = new Hashtable();
                    newRoom.Add("name", m_sRoomName);
                    newRoom.Add("isGame", true);
                    newRoom.Add("maxUsers", 5);

                    smartFox.CreateRoom(newRoom);

                   // but next instruction raise exception because
                   // GetActiveRoom return null WHY???
                   Debug.Log( smartFox.GetActiveRoom().GetName() );



And after create room, "method" SFSEvent.onRoomAdded no called, may by I do something wrong?

Please help...

Thanks!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 26 Jul 2010, 16:11

There can be many reasons - here are some wild guesses

* your client is not logged in, and cannot thus create a room
* you cannot query ActiveRoom before the server has send the client a new room list update. SFS is a request/response system, so you do not join the new room before the server has send the response to the room creation request

To debug:
* try to subscribe to onRoomCreateError (or similar) and see if server returns an error
* subscribe to the DebugMessage callback and check the console for information
* check server console to see if room is created or not


Did you try to run some of the example projects and hack those to help you along?

Best
Thomas
DziD
Posts: 4
Joined: 20 Jul 2010, 11:41

Postby DziD » 27 Jul 2010, 07:53

Hi Thomas. Thanks for reply!
* subscribe to the DebugMessage callback and check the console for information

I enable SFS DEBUG and I'am getting next message:

[SFS DEBUG] You haven't joined any rooms!
In order to interact with the server you should join at least one room.
Please consult the documentation for more infos.

But I don't know what it mean..:( Maybe in it message saying what before create room I must connect to something room? or something else?

* your client is not logged in, and cannot thus create a room

Regards LOGIN My Client is 100% login because I'am try to create room in OnLogin Method subscribed to onLogin.

* check server console to see if room is created or not

Rooms doesn't created in server I'am not view it in server console.

* try to subscribe to onRoomCreateError (or similar) and see if server returns an error


I'am subscribe to onRoomCreateError, but this method not call

My IDEAS regarding create room end... :(((

Any IDEAS how fix this problem?

P.S. Maybe need write server extension, that create room, and sending command to create room on it?

Thanks!
DziD
Posts: 4
Joined: 20 Jul 2010, 11:41

Postby DziD » 27 Jul 2010, 10:32

Fuuuuuufff I did it! It work...

First before creating a room you must JOIN to any room on a server and all will be OK!

Thanks All!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Jul 2010, 13:28

Ahh yeah - you found out the issue yourself then. Super!

Good luck

/Thomas

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 18 guests