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!
ExtensionDescriptor in SmartFoxClientAPI.NewRoomDescriptor
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.
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)
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)
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
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);
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#:
And after create room, "method" SFSEvent.onRoomAdded no called, may by I do something wrong?
Please help...
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!
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
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
* 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
Hi Thomas. Thanks for reply!
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?
Regards LOGIN My Client is 100% login because I'am try to create room in OnLogin Method subscribed to onLogin.
Rooms doesn't created in server I'am not view it in server console.
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!
* 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!
-
- Posts: 1297
- Joined: 14 Mar 2008, 07:52
- Location: Sweden
Return to “.Net / Unity3D API”
Who is online
Users browsing this forum: No registered users and 38 guests