room.setGroupId problem

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

aliko
Posts: 117
Joined: 09 Mar 2013, 16:26

room.setGroupId problem

Postby aliko » 23 Feb 2016, 09:45

Hello,

I updated roomgroupid after game started like below from serverside.

Code: Select all

room.setGroupId("games_High_s");


but this room is listing on games_High group still and cannot remove from zone monitor.
screen attached.

What is my fault can you help me please? My aim is to disable send roomvars update for started games to game_High group listeners.

Best Regards

error.jpg
(68.76 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: room.setGroupId problem

Postby Lapo » 23 Feb 2016, 10:16

Hi,
for starters it is not possible to change RoomGroup after the room has been created. If you do that will mess up the Room internally.

My aim is to disable send roomvars update for started games to game_High group listeners.

RoomVariableUpdate events cannot be disabled by changing a Room's group.

I am not sure I fully understand what you're trying to say here. You mean you don't want users to be able to update Room Variables once the game is started?

thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
aliko
Posts: 117
Joined: 09 Mar 2013, 16:26

Re: room.setGroupId problem

Postby aliko » 23 Feb 2016, 10:49

Sorry let me give more details,
This is a backgammon game.

I have a game group games_High. In this group there are 5 games waiting oppenent and 500 games started.
When a new user login and subscribe game_High, he will recieve 505 games details.

But he does not need 500 started games data oy any updates for them.
I want to send him only game that are waiting oppenent.

I hope now you understand me :(

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

Re: room.setGroupId problem

Postby Lapo » 23 Feb 2016, 11:10

Ok, now it is clear, thank you.
I think you need an entirely different strategy. I would suggest you don't subscribe the client to the group, this way he will not receive any room lists.

What you need to do is running a server side findRooms(...) call. Here you can filter all the Rooms that are in "wait" state and send the list to User.
Take a look at this article, which describes MatchExpressions which are used by the findRoom method:
http://docs2x.smartfoxserver.com/Advanc ... s/game-api

Also we wrote a recent article about MatchExpressions here: http://smartfoxserver.com/blog/?p=426

Here is the pseudo code of what I am talking about:

Code: Select all

// Filter all Rooms that have a RoomVariable 'waiting' set to true
MatchExpression exp = new MatchExpression('waiting', BoolMatch.EQUALS, true);

// Obtain the list of Rooms from a specific group
List<Room> rooms = getParentZone().getRoomListFromGroup("MyRoomGroup");

// Find up to 5 rooms matching the provided expression
List<Room> filteredRoomList = getApi().findRooms(rooms, exp, 5);
                   
// ... Send the Room list to the client ...


Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
aliko
Posts: 117
Joined: 09 Mar 2013, 16:26

Re: room.setGroupId problem

Postby aliko » 25 Feb 2016, 08:05

Hi Lapo,

Thank you very much for your detailed answer.
In this case how can I synchronize open tables with clients?
- Send open tables to clients periodly?
- When a new room oppened ?
- or another way do you have a suggest for me?


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

Re: room.setGroupId problem

Postby Lapo » 25 Feb 2016, 09:26

If you need constant updates, then just use the default room list.
It really doesn't cost you much bandwidth. The protocol is very efficient and compressed. You get the list of Rooms in one packet and then you only get updates when a room is created or removed which is an extremely small amount of data.

In your example with 500 Rooms the amount of data transferred is really low and much lower than the average webpage you can access in any website, with all their javascript and css, image etc...
You should really not worry about that.

On the client you can filter out the games that are already started (by checking the relative Room Variable) and show only those that are waiting for players.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 13 guests