FindRoomRequest has proplem with MatchExpression

Post here your questions about the C++ API for SFS2X

Moderators: Lapo, Bax, MBagnati

errusteven
Posts: 4
Joined: 24 Jul 2014, 03:52

FindRoomRequest has proplem with MatchExpression

Postby errusteven » 06 Nov 2014, 04:39

Hi Bax, Lapo and MBagnati.

I use FindRoomRequest to filter room but it's not work.

My situation:
I have 4 rooms. One has max user = 2, and three have max user = 4
I want to filter all rooms have RoomProperties.MAX_USERS = 4, so I try use MatchExpression

void MyServer::filterRoom()
{
boost::shared_ptr<int> matchValue(new int(4));
boost::shared_ptr<MatchExpression> expr(new MatchExpression(RoomProperties::MAX_USERS, NumberMatch::EQUALS, matchValue, MatchExpression::MatchExpressionValueType::MatchExpression_ValueOther));
// Send request
boost::shared_ptr<IRequest> request(new FindRoomsRequest(expr));
mSmartFox->Send(request);
}

And there is no room in FindRoomResponse. But when I change NumberMatch::EQUALS to NumberMatch::GREATER_OR_EQUAL_THAN, I have 4 rooms in my response.
So I try to use NumberMatch::LESS_OR_EQUAL_THAN, the response has the same response as NumberMatch::EQUALS. I think it's not work when use NumberMatch::LESS_OR_EQUAL_THAN and NumberMatch::EQUALS
My API version is 1.1.4 and Smartfox Server 2.8.4

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

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 11 Nov 2014, 17:30

Sorry for the delay. We'll try to replicate the problem and report back.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
MBagnati
Posts: 125
Joined: 12 Feb 2013, 10:57

Re: FindRoomRequest has proplem with MatchExpression

Postby MBagnati » 12 Nov 2014, 09:11

Hi,
I have investigated the issue and I have found an error in API library.
As temporary workaround please use a double datatype to declare the matchValue.
In your filterRoom function, please temporarly replace

Code: Select all

   boost::shared_ptr<int> matchValue(new int(4));


with

Code: Select all

   boost::shared_ptr<double> matchValue(new double(4));


Error will be fixed in next API version.

Let me know if this workaround returns expected results
Thanks
mattv
Posts: 9
Joined: 10 Aug 2014, 07:56

Re: FindRoomRequest has proplem with MatchExpression

Postby mattv » 02 Jun 2015, 12:40

Hi,

On SFS2X 2.10.0 and latest Client 1.6.0 for unity3D.
MatchExpression returns all rooms if condition not fulfilled.

Expression :
String isTeam "Y"
Bool isGameStarted false

If the above conditions not satisfied, it should return zero room. But i get all rooms with isTeam "Y"&"N", isGameStarted true.
Able to replicate this scenarios many times.

Need help from SFS support to find a resolution. Thank you!

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

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 02 Jun 2015, 19:22

Can you show me the actual code of the request?
Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
mattv
Posts: 9
Joined: 10 Aug 2014, 07:56

Re: FindRoomRequest has proplem with MatchExpression

Postby mattv » 03 Jun 2015, 03:24

Lapo wrote:Can you show me the actual code of the request?
Thanks

Hi Lapo,

Thanks for the help.

Below is the client codes :

Code: Select all

      private void onRoomFindSingle ()
      {
         roomFindStarted = true;
         registerSFSeventsFindRoomResult ();
         // Start the main game
         // Prepare match expression
         MatchExpression exp = new MatchExpression (RoomProperties.IS_GAME, BoolMatch.EQUALS, true).And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true);
         exp.And ("isTeam", StringMatch.EQUALS, "N");
         exp.And ("isGameStarted", BoolMatch.EQUALS, true);

         smartFox.Send (new Sfs2X.Requests.FindRoomsRequest (exp));

      }
      
      private void onRoomFindTeam ()
      {
         roomFindStarted = true;
         registerSFSeventsFindRoomResult ();
         // Start the main game
         // Prepare match expression
         MatchExpression exp = new MatchExpression (RoomProperties.IS_GAME, BoolMatch.EQUALS, true).And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true);
         exp.And ("isTeam", StringMatch.EQUALS, "Y");
         exp.And ("isGameStarted", BoolMatch.EQUALS, false);
         smartFox.Send (new Sfs2X.Requests.FindRoomsRequest (exp));
      }


Descriptions : two static room configuration. Single Room and Team Room with persistent room variables isTeam:string, isGameStarted:boolean.
Summary : Call onRoomFindSingle (), It should only return single room, but the result returns Single Room and Team Room (when team room has a game in progress. isGameStarted=true).
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 03 Jun 2015, 09:26

Thanks.
Since I don't have your setup to test I would like you to ask you to try a couple of tests.

Take one of the two expressions and test with only the first element:

Code: Select all

MatchExpression exp = new MatchExpression (RoomProperties.IS_GAME, BoolMatch.EQUALS, true)


If this returns the expected result add the next condition, e.g.:

Code: Select all

exp.And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true)


This way we can pin down which condition is not met, then we'll investigate the reason why it's not returning as expected.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
mattv
Posts: 9
Joined: 10 Aug 2014, 07:56

Re: FindRoomRequest has proplem with MatchExpression

Postby mattv » 03 Jun 2015, 10:15

Lapo wrote:Thanks.
Since I don't have your setup to test I would like you to ask you to try a couple of tests.

Take one of the two expressions and test with only the first element:

Code: Select all

MatchExpression exp = new MatchExpression (RoomProperties.IS_GAME, BoolMatch.EQUALS, true)


If this returns the expected result add the next condition, e.g.:

Code: Select all

exp.And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true)


This way we can pin down which condition is not met, then we'll investigate the reason why it's not returning as expected.

thanks



It helps to narrow the expressions :

Tests for 1-3 rules, Ok, works 10 out of 10.
MatchExpression exp = new MatchExpression (RoomProperties.IS_GAME, BoolMatch.EQUALS, true).And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true);
exp.And ("isTeam", StringMatch.EQUALS, "N");


Test fails with 4th rule, return room with isTeam=Y. isGameStarted=true

MatchExpression exp = new MatchExpression (RoomProperties.IS_GAME, BoolMatch.EQUALS, true).And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true);
exp.And ("isTeam", StringMatch.EQUALS, "N");
exp.And ("isGameStarted", BoolMatch.EQUALS, true);
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 03 Jun 2015, 10:20

Can you make doubly sure (via the AdminTool > Zone Monitor) that the isGameStarted variable exists and is set as expected?

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
mattv
Posts: 9
Joined: 10 Aug 2014, 07:56

Re: FindRoomRequest has proplem with MatchExpression

Postby mattv » 04 Jun 2015, 01:56

Lapo wrote:Can you make doubly sure (via the AdminTool > Zone Monitor) that the isGameStarted variable exists and is set as expected?

thanks

Hi Lapo,

SS01.png
(48.02 KiB) Not downloaded yet

SS02.png
(48.74 KiB) Not downloaded yet


OK, checked zone monitor several times to ensure the variable exists for the rooms and has correct value to trigger the scenario.

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

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 04 Jun 2015, 08:08

Thanks.
One more thing: what happens if you simply use this, instead

Code: Select all

MatchExpression exp = new MatchExpression ("isGameStarted", BoolMatch.EQUALS, true);


I'd like to understand if the problem is with the specific variable or with the entire expression's chain.
Lapo

--

gotoAndPlay()

...addicted to flash games
mattv
Posts: 9
Joined: 10 Aug 2014, 07:56

Re: FindRoomRequest has proplem with MatchExpression

Postby mattv » 08 Jun 2015, 09:49

Lapo wrote:Thanks.
One more thing: what happens if you simply use this, instead

Code: Select all

MatchExpression exp = new MatchExpression ("isGameStarted", BoolMatch.EQUALS, true);


I'd like to understand if the problem is with the specific variable or with the entire expression's chain.


Did a quick test, 1 variable expression, works 10/10 for true&false scenario.
The problem pop-up for expressions chain, of a string and bool type. e.g, expression filter "Y"&true return rooms with"Y"&true, "N"&true
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 08 Jun 2015, 16:58

I have tested your scenario and I was not able to reproduce any problem.
I've used a chain of two and a chain of four expressions such as this:

Code: Select all

MatchExpression expr = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true).And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true).And("stringVar", StringMatch.EQUALS, "Y"). And("boolVar", BoolMatch.EQUALS, true);

sfs.Send( new FindRoomsRequest(expr));


And always got back the right response.
I am testing on the latest 2.10 release, but I am not even aware of bugs in older versions.

The only thing that stands out is the very old version of your client side API (1.1.4?) Please go here:
http://www.smartfoxserver.com/download/sfs2x#p=client

And download version 1.5.7 (not 1.6.0, since you have an old server). Then try with the new API and let me know.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
mattv
Posts: 9
Joined: 10 Aug 2014, 07:56

Re: FindRoomRequest has proplem with MatchExpression

Postby mattv » 09 Jun 2015, 07:12

Lapo wrote:I have tested your scenario and I was not able to reproduce any problem.
I've used a chain of two and a chain of four expressions such as this:

Code: Select all

MatchExpression expr = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true).And (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true).And("stringVar", StringMatch.EQUALS, "Y"). And("boolVar", BoolMatch.EQUALS, true);

sfs.Send( new FindRoomsRequest(expr));


And always got back the right response.
I am testing on the latest 2.10 release, but I am not even aware of bugs in older versions.

The only thing that stands out is the very old version of your client side API (1.1.4?) Please go here:
http://www.smartfoxserver.com/download/sfs2x#p=client

And download version 1.5.7 (not 1.6.0, since you have an old server). Then try with the new API and let me know.

Thanks


Sorry, piggyback to this old thread.
The fourth message of this thread, the problem is with this setup of mine : SFS2X 2.10.0 (OSX Yoesmite) and Client 1.6.0 for unity3D.
When i have more bandwidth, will do a fresh install and simple test client to replicate this error.
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: FindRoomRequest has proplem with MatchExpression

Postby Lapo » 09 Jun 2015, 07:31

Sorry, I misread the setup by scrolling the old posts back to the first one.

When i have more bandwidth, will do a fresh install and simple test client to replicate this error.

Ok. Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C++ API”

Who is online

Users browsing this forum: No registered users and 1 guest