Private Message and FindUsersRequest

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

alexcy32
Posts: 22
Joined: 14 May 2013, 16:48

Private Message and FindUsersRequest

Postby alexcy32 » 27 Sep 2015, 11:50

Dear All,

I have 2 rooms, rA and rB. I have 2 users, uA and uB. uA joins room rA and uB joins room rB. Both rooms are non-game rooms.

FIRST PROBLEM:
-----------------------

If I use the following AS3 code I get no hits back for neither of the rooms from either user:

FindUsersInSpecificRoom2("rA");
FindUsersInSpecificRoom2("rB");

function FindUsersInSpecificRoom2(roomToCheck:String)
{
sfs.addEventListener(SFSEvent.USER_FIND_RESULT, onUserFindResult);
trace("Trying to find users: "+ roomToCheck);
var exp:MatchExpression = new MatchExpression(RoomProperties.NAME,StringMatch.EQUALS,roomToCheck);
// Find the users
sfs.send(new FindUsersRequest(exp)); }

function onUserFindResult(evt:SFSEvent):void
{
trace("Users found: " + evt.params.users);
}


* Even if I change the matchecpression to: var exp:MatchExpression = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, false)
I still get no hits back even if both the rooms are non-game rooms :/

SECOND PROBLEM:
-----------------------

When I am trying to send a private message from uA to uB using:
SendPrivateMessage("uA","test message");

function SendPrivateMessage(recipient:String,bodyOfMessage:String)
{
var recipientUser:User = sfs.userManager.getUserByName(recipient);
// Send it to SFS
sfs.send(new PrivateMessageRequest(bodyOfMessage, recipientUser.id));
}


It does not work. It's like uA and uB do not see each other. If I put both users in the same room the sending message part works OK. The FIRST PROBLEM still remains.

Thank you for all the assistance
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Private Message and FindUsersRequest

Postby Lapo » 28 Sep 2015, 13:50

Hello,

P #1)
What Room Group do these Rooms (rA, rB) belong to? Is it the "default" group or something else? Are you sure your users are subscribed to whatever Room Group these Rooms belong to?

P #2
Private messages require users to be in the same Room. If you want two users to chat regardless of the Room they are in you should use Buddy Messages, and use the Buddy List.

The main reason here is that two users in two different Rooms don't know about each others. Using buddies they can know about each other and this "knowledge" (or visibility) is independent of the joined Rooms.

Overview of the Buddy List API: http://docs2x.smartfoxserver.com/Advanc ... y-list-api

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
alexcy32
Posts: 22
Joined: 14 May 2013, 16:48

Re: Private Message and FindUsersRequest

Postby alexcy32 » 28 Sep 2015, 16:45

1) They belong to the same default group but they are not subscribed to it explicitly. But when I use sfs.roomlist I can see all the rooms that I want to be able to search using FindUsersRequest. Do they have to be subscribed to the default group explicitly to use the FindUsersRequest?
They join the zone and room and then I perform the user search function. Do I need to subscribe them to the default group prior doing the FindUsersRequest using SubscribeRoomGroupRequest?

2) Yes I figured that out. thank you :)
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Private Message and FindUsersRequest

Postby Lapo » 29 Sep 2015, 09:40

alexcy32 wrote:1) They belong to the same default group but they are not subscribed to it explicitly. But when I use sfs.roomlist I can see all the rooms that I want to be able to search using FindUsersRequest. Do they have to be subscribed to the default group explicitly to use the FindUsersRequest?
They join the zone and room and then I perform the user search function. Do I need to subscribe them to the default group prior doing the FindUsersRequest using SubscribeRoomGroupRequest?

The don't need to subscribe explicitly because each user is auto-subscribed at login time to all groups specified in your Zone's default groups (see Zone Configurator in Admin Tool)

By default SmartFox creates a single Room Group called "default" and auto-subscribes all users to it (via the "default groups" in the Zone Configurator). Also when you create a new Room without specifying a group the "default" group is used.

Can you give me more details as to what SFS2X version you're using and what API version too?
The API version is found by tracing the SmartFox.version property.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 20 guests