problem when creating Room

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Mizuka
Posts: 1
Joined: 17 Apr 2021, 13:43

problem when creating Room

Postby Mizuka » 17 Apr 2021, 14:09

Hello in my project the user can buy a house and after he rents the house and tries to join to his house, the serve has to creat a temporary room for him

and this room stays as long as the user is inside it, and when the user left the room, it becomes destroyed

I'm using this code :

Code: Select all

         // --- Room params -------------------------

            var roomObj = {}
            roomObj.name = "BlastRoom"
            roomObj.maxU = 12
            roomObj.isTemp= true
         
         
            roomVars = [
            {name:"RoomID", val: 1},
            {name:"Room",      val: 1},
            {name:"Accr",    val: 1},]
            New_Room = _server.createRoom(roomObj, null, true, true, roomVars)

            var New_Room_ID = New_Room.getId()

            // Joining The Created Room In Database.
            _server.joinRoom(user, -1, true, New_Room_ID)



when the user try to go to his house, the temporary Room is created succesfully and the user can go to his house,
but when the user try to left this temporary room to any basic room of project a wrong message come from server: user already exist in this room
,
and when someone else (another user) try to join the same temporary room ( to visit his friend in his home for example) a wrong message come from server: room already exist.

So I think the room isn't created well or should I use destroyRoom?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: problem when creating Room

Postby Lapo » 19 Apr 2021, 07:24

Hi,
Mizuka wrote:and this room stays as long as the user is inside it, and when the user left the room, it becomes destroyed

The room is created with the isTemp flag set to true, which makes it so that the Room is removed when the last user leaves. If you don't want this behavior you should change the flag to false.

when the user try to go to his house, the temporary Room is created succesfully and the user can go to his house,
but when the user try to left this temporary room to any basic room of project a wrong message come from server: user already exist in this room

This is not very clear. If you're trying to join a Room that you've already joined you will get that error. Otherwise you shouldn't see it.
I'd recommend double checking what Rooms you're joining especially if you allow users to join more than one at the same time.

and when someone else (another user) try to join the same temporary room ( to visit his friend in his home for example) a wrong message come from server: room already exist.

The error "Room already exists" cannot be caused by a join request. It can only be caused by attempting to create a Room with the same name of another Room that already exists.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 35 guests