Private (owner-only) BuddyVariables

Post here your suggestions for new possible features in SmartFoxServer 2X.

Moderators: Lapo, Bax

User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Private (owner-only) BuddyVariables

Postby rjgtav » 20 Jul 2013, 00:49

Hello,

These last days I've been working on implementing a BuddyList system for a project that I've been working on and I've got an idea for a new feature (actually, this can lead to two different feature suggestions).
This BuddyList system has all the common features: add/remove buddy, buddy requests, etc. and we also wanted to implement an "Ignore Requests" feature. Basically, this is a flag that, when true, the user doesn't receive any AddBuddy invitations.

As this is a BuddyList system specific setting, I don't think storing this setting at the database would be a great idea, in terms of organization. Therefore, I've concluded that the best way to store it would be through the BuddyStorage system. So I've decided to use Offline BuddyVariables, but there are some problems with them for this use case:
1. Offline BuddyVariables are transmitted to the owner's buddies, even when he's not online;
2. When updated, if you want to send the update to the owner, by enabling the updateClients flag, it will also update all the owner's buddies about that change;

With this in mind, I tried to find a way to actually separate offline variables from "private" ones. I've noticed that when the BuddyList system is going to send the BuddyVariables to the owner, it calls only the loadList() method of the StorageClass, while when it wants to load the variables from an offline user, it calls the getOfflineVariables() method. So, in order to accomplish what I wanted, I added a separate method for filtering the "private" variables from the buddyList file and I only call it at the end of the loadList() method, and then set these variables to the BuddyProperties object.
But, there's also a problem with this approach. By doing that, the variables are set as online BuddyVariables (I could even turn them into offline, but it would lead to the same problem), and so, the owner's buddies were still receiving them.

So... after struggling for a while, I've decided to continue, I've let my current implementation, which sends the variable only to the owner and doesn't send it when he's not online, but also sends it to his buddies when he's online...

In order to solve this, which I think is a small gap on the whole API, I've came with two ideas. The first one is pretty straight forward, simply implement an extra flag for the SFSBuddyVariable class, for example called isPrivate(), and then update the code responsible for sending the BuddyVariables update so that it doesn't send the update for these kind of variables.

The second idea, which gives a lot more customization possibilities to the developer, is creating a SystemControllerFilter that, instead of acting with the data sent from the client before reaching the Server API, it would act before the data sent from the server actually went through the network. This would enable us (developers) to actually filter the data that is going to be sent by the Server API. In my use case, with that feature, I could simply intercept the BUDDY_VARIABLES_UPDATE event and remove the "private" variables from there.

What do you think?

Thanks for reading
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
User avatar
Lapo
Site Admin
Posts: 19676
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Private (owner-only) BuddyVariables

Postby Lapo » 29 Jul 2013, 09:30

Hi,
I've got lost at the beginning of the description. Supposing I set to true the Ignore-Add-Buddy flag how is my Buddy List is going to work at all?
Does it mean that people who want to add me to their Buddy Lists can do it without asking?
Or does it mean that no one will be able to add me because I am ignoring all those requests?

Also a simple way to implement "private settings" for a certain user is to keep those settings on the User object itself, via the User.get/setProperty(...)

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Private (owner-only) BuddyVariables

Postby rjgtav » 29 Jul 2013, 10:55

Hi Lapo,

Yes, this was a feature requested by the client. Basically, when the user is ignoring AddBuddyRequests, no one will be able to add him as a buddy, as no invitation will be sent to him.

Lapo wrote:Also a simple way to implement "private settings" for a certain user is to keep those settings on the User object itself, via the User.get/setProperty(...)

The problem with the get/setProperty(...) methods is that those properties are server-side only, but I also needed them to update at their owner client. This may be similar to one feature that sometimes is requested, which is UserVariables which are only "seen" by the server and the user where those variables are attached to.

As this can be a rarely needed feature, I was suggesting the filter that acts after the server API and before the packet is sent, so that the developer can get a better control regarding what data is sent to the clients and also implement these kind of features.

Sorry for the confusion on my previous post,
Thanks
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.

Return to “2X Features Wish List”

Who is online

Users browsing this forum: No registered users and 1 guest