http://docs2x.smartfoxserver.com/api-do ... quest.html
The developers are using the FindUsersRequest() Constructor
When they use it multiple times it fails after the first request.
However, if the stagger it by sending them 5 secs apart it works.
Any idea what could be causing this ?
FindUserRequest() constructor
Re: FindUserRequest() constructor
Hello,
can you be more specific and report what is the failure exactly? Is it a client side error or server side?
And what error is it?
thanks
can you be more specific and report what is the failure exactly? Is it a client side error or server side?
And what error is it?
thanks
Re: FindUserRequest() constructor
Hi Lapo,
The client does not receive a response from SmartFox if the requests are sent out too close together
There are no error messages.
Client side call fails when there is No staggering between requests
Client side call succeeds after introducing a 5 sec delay between calls, which is not ideal
The client does not receive a response from SmartFox if the requests are sent out too close together
There are no error messages.
Client side call fails when there is No staggering between requests
Client side call succeeds after introducing a 5 sec delay between calls, which is not ideal
Re: FindUserRequest() constructor
Here is a general outline of our current implementation of SmartFox for the purposes of the client relaying notifications to other clients through SmartFox.
- After the client connects and joins a "Notifications" lobby, we make a SetUserVariablesRequest to set the Webkinz user ID for the user in SmartFox
var userVars:Array = new Array();
userVars.push(new SFSUserVariable("wkName", _notificationService.userId));
_sfs.send(new SetUserVariablesRequest(userVars));
- When we need to notify another user, requests get placed into a queue, and we process them one by one
- First, we send a FindUsersRequest specifying the other users Webkinz ID to find out their assigned SmartFox ID
var exp:MatchExpression = new MatchExpression("wkName", NumberMatch.EQUALS, wkID);
_sfs.send(new FindUsersRequest(exp));
- Once the SFSEvent from the FindUsersRequest is received we check if an online user was found and we send a PrivateMessageRequest to them, specifying the SmartFox user ID as the destination user
The part that caused issues for us was when the client is told to notify multiple users. In this case we still queue the processing and handle notifying one user at a time, but still when we did not have a delay there would be scenarios where the FindUsersRequest would be sent out and we would never receive an SFSEvent.USER_FIND_RESULT event from SmartFox.
When we added a one second delay after processing one request before going on to the next one, the event would always come through successfully.
- After the client connects and joins a "Notifications" lobby, we make a SetUserVariablesRequest to set the Webkinz user ID for the user in SmartFox
var userVars:Array = new Array();
userVars.push(new SFSUserVariable("wkName", _notificationService.userId));
_sfs.send(new SetUserVariablesRequest(userVars));
- When we need to notify another user, requests get placed into a queue, and we process them one by one
- First, we send a FindUsersRequest specifying the other users Webkinz ID to find out their assigned SmartFox ID
var exp:MatchExpression = new MatchExpression("wkName", NumberMatch.EQUALS, wkID);
_sfs.send(new FindUsersRequest(exp));
- Once the SFSEvent from the FindUsersRequest is received we check if an online user was found and we send a PrivateMessageRequest to them, specifying the SmartFox user ID as the destination user
The part that caused issues for us was when the client is told to notify multiple users. In this case we still queue the processing and handle notifying one user at a time, but still when we did not have a delay there would be scenarios where the FindUsersRequest would be sent out and we would never receive an SFSEvent.USER_FIND_RESULT event from SmartFox.
When we added a one second delay after processing one request before going on to the next one, the event would always come through successfully.
Re: FindUserRequest() constructor
From the client side there is a limit of one FindUserRequest per second, to avoid spamming from malicious users.
If you take a look at the server side logs you will notice that an error is generated if you send more than 1 FindUserReq per second.
If you need to run multiple searches per second I would recommend two possible ways:
1- run a single client side "FindUser" with a compounded MatchExpression. E.g.
.
This way you can search any number of users with a single request
2- run a server side search, which has not time limits. In other words, you can send all the IDs that need to be searched to your custom Extension and perform the FindUser call from server side. Once again it would be best to optimize the search by aggregating the IDs in the MatchExpression.
Running the FindUserRequest from server side is done via
More details are found in the javadoc:
Hope it helps
If you take a look at the server side logs you will notice that an error is generated if you send more than 1 FindUserReq per second.
If you need to run multiple searches per second I would recommend two possible ways:
1- run a single client side "FindUser" with a compounded MatchExpression. E.g.
Code: Select all
var searchExp:MatchExpression = new MatchExpressions("name", StringMatch.EQUALS, "name1").or("name", StringMatch.EQUALS, "name2")... etc...
This way you can search any number of users with a single request
2- run a server side search, which has not time limits. In other words, you can send all the IDs that need to be searched to your custom Extension and perform the FindUser call from server side. Once again it would be best to optimize the search by aggregating the IDs in the MatchExpression.
Running the FindUserRequest from server side is done via
Code: Select all
getApi().findUser(...);
More details are found in the javadoc:
Hope it helps
Re: FindUserRequest() constructor
How can we send the result of user list findUser(..) to client?
Re: FindUserRequest() constructor
You can serialize the User object by calling toSFSArray().
Like this:
On the client side you can loop through the SFSArray and build a User list by calling SFSUser.fromArrayList(...) and passing each item of the array.
Hope it helps
Like this:
Code: Select all
List<User> userList = getApi().findUser(...);
ISFSObject resObj = new SFSObject();
ISFSArray userListData = new SFSArray();
for (User user : userList)
{
userListData.addSFSArray(user.toSFSArray());
}
resObj.putSFSArray("UserList", userListData);
send("response", resObj, targetUser);
On the client side you can loop through the SFSArray and build a User list by calling SFSUser.fromArrayList(...) and passing each item of the array.
Hope it helps
Who is online
Users browsing this forum: No registered users and 125 guests