changing a room name

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

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

Re: changing a room name

Postby Lapo » 12 Feb 2013, 17:38

From client side, no. I've explained it in my previous post :)
It evidently poses a security problem, anyone can go and change the Room names from an insecure source (the client)

From server side you can do it, by passing null as the owner of the Room.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
gg
Posts: 90
Joined: 19 Sep 2010, 21:16
Contact:

Re: changing a room name

Postby gg » 13 Feb 2013, 01:55

How do I do it server-side? Please don't point me to the API unless you can show me how to use it.

I found this and tried it: http://docs2x.smartfoxserver.com/api-do ... quest.html but I'm not even sure how to use it:
- the sfs object needs to be initialized - to what? I tried to substitute sfs with gameExt but:
Room theRoom = gameExt.getRoomByName("Gonzo's Room");
the getRoomByName function is not recognized by gameExt.
- everything else needs to be imported; and even after I import everything, I can't find what to import to use ChangeRoomNameRequest in Java. So I must be using it wrongly.

So I tried the following:
gameExt.getParentRoom().setName(Integer.toString(gameExt.seconds) + " " + gameExt.p1Name + " vs " + gameExt.p2Name);

This changes the room name but the already logged in users don't see it. If a new user logs in, he sees the new room name but not the old ones.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: changing a room name

Postby Lapo » 13 Feb 2013, 08:37

For starters you are looking in the wrong documentation. That's the client-side javadoc. If you want to work on the server side you should look at the server-side javadoc: http://docs2x.smartfoxserver.com/api-do ... oc/server/

If your Extension is attached to a Zone you can obtain the Room like this:

Code: Select all

Room room = getParentZone().getRoomByName(...)


If your Extension is attached to a Room:

Code: Select all

Room room = getParentRoom()


Then you just invoke the server side API:

Code: Select all

getApi().changeRoomName(null, room, "TheNewName");
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
gg
Posts: 90
Joined: 19 Sep 2010, 21:16
Contact:

Re: changing a room name

Postby gg » 14 Feb 2013, 22:44

Lapo wrote:For starters you are looking in the wrong documentation. That's the client-side javadoc. If you want to work on the server side you should look at the server-side javadoc: http://docs2x.smartfoxserver.com/api-do ... oc/server/

If your Extension is attached to a Zone you can obtain the Room like this:

Code: Select all

Room room = getParentZone().getRoomByName(...)


If your Extension is attached to a Room:

Code: Select all

Room room = getParentRoom()


Then you just invoke the server side API:

Code: Select all

getApi().changeRoomName(null, room, "TheNewName");

Thank you so much! :) So was I looking at the Actionscript API in my previous post, or what is the link that I posted?

I saw "java.lang.Object" and thought it was Java code, thus server side.

java.lang.Object
extended by sfs2x.client.requests.BaseRequest
extended by sfs2x.client.requests.ChangeRoomNameRequest
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: changing a room name

Postby Lapo » 15 Feb 2013, 08:26

You were looking at the Java client API
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
gg
Posts: 90
Joined: 19 Sep 2010, 21:16
Contact:

Re: changing a room name

Postby gg » 17 Feb 2013, 02:46

Lapo wrote:You were looking at the Java client API

thanks Lapo!
gg wrote:I wasted at least 1 hour trying to figure out how to set allowNameChange to true. It seems I'm the only idiot who couldn't infer to do the following from the API:

var permissions:RoomPermissions = new RoomPermissions();
permissions.allowNameChange = true;
settings.permissions = permissions;

Thanks to
http://ext2-in-user-space.googlecode.co ... xHelper.as

Warning for anyone that does what I do. It seems that by creating my own permissions object and I only specify allowNameChange, it overwrites the old default allowPublicMessages. So if you change allowNameChange like I did, you need to also explicitly say
permissions.allowPublicMessages = true
(because it seems by default, not specifying this makes allowPublicMessages false)

Note I still have <flags>ROOM_NAME_CHANGE,PUBLIC_MESSAGES</flags> in BasicExamples.zone.xml so I didn't change anything.
If you don't do this, you can't send public chat messages in that room. Weirdly enough, the initial error was that something was wrong with log4j (that it wasn't initialized properly); I did play with log4j.properties, but when I changed it back to what it was originally, I still couldn't send public messages in my game room, although the error now was "Room does not support public messages"

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 61 guests