Re-initializing / Updating BuddyList - Fail!

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

Moderators: Lapo, Bax

User avatar
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Re-initializing / Updating BuddyList - Fail!

Postby omnivibe » 18 Aug 2011, 13:57

When I start the application, I'm able to initialize the buddylist, play with it perfectly... everything is fine.

The problem is that I need to refresh the properties of sfs.buddyManager.buddyList live during runtime- since buddies will be added to/removed from the database storage at runtime.

When I try to re-initialize the list, I get:

[SFS - WARN] InitBuddyRequest error Buddy List is already initialized.

And the SFSBuddyEvent.BUDDY_LIST_INIT event is never fired....

Please help!

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

Postby rjgtav » 18 Aug 2011, 15:40

Hi. When you initialize the buddylist, what the server does is loading the buddylist, so why do you need to reload the whole buddylist? Isn't it better if you do the changes also to the buddylist when you do them to the database?
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
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 18 Aug 2011, 16:18

The changes to the database are done via serverside logic, not necessarily triggered by the user themselves...

They have no way of knowing when this change happens, but they only need to know before creating a room basically.

I could try pulling the real buddylist via a database call, then comparing with what's in the BuddyListManager so far, and add/remove via the API as necessary... but before I try that:

1) will it work? (i.e. addbuddy when the buddy is already added on the backend)

2) Is it really the most elegant solution? A simple ReInitialize or Destroy()/Initialize() or some way of resyncing the buddyList array would be much better imho...
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 18 Aug 2011, 16:28

What i was suggesting is, when you, for example, add a buddy on your server-side logic, you also add the buddy to the user's buddylist.
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
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 18 Aug 2011, 16:30

How can I push that change to the client live during runtime?
User avatar
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 18 Aug 2011, 16:45

Ah- there's a critical piece of the puzzle missing in my description.

"Serverside Logic" here is all driven by the webserver, not SFS.

I.e. someone calls example.com/addbuddy?username=foo, and it gets pushed into the BuddyListStorage database.

If there were a hook from that webserver into the Java Extension... then I think your solution of calling serverside AddBuddy would work...

1) Is that correct?
2) Is there such a hook?
3) If there isn't, how can a single rusty Java programmer create one reliably in 2 hours or less? :)
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 18 Aug 2011, 16:55

Ah i understand now. Well, I'm pretty sure there is a way to comminicate with an extension from the webserver... In SFS1x it was possible...
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
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 18 Aug 2011, 16:55

I have an interesting idea...

1) Create a reserved room on the system called "ControlRoom"
2) Create a Room-Level extension which is only for that room
3) Give this room a password which is only known to the backend webserver
4) When the webserver needs to update a buddy list, it connects to SFS and joins this room- while loading the extension (extension will only allow a specific username, and that username must pass the authentication of the Zone-level pw check)
5) Extension processes specific commands... like addbuddy() and removebuddy(). Perhaps even other administration-like functions such as KickBanUser, etc.

Questions-
1) What'ya think?
2) If this is a good idea, is there away to optimize so that it doesn't require reconnecting each time? I.e. a way to maintain a persistent connection? backend environment is .NET/IIS
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 18 Aug 2011, 16:59

Isn't a zone-level extension better? Also, sorry i never worked with a webserver, so i don't know how to make it connect with sfs. But i can google it :-)
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
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 18 Aug 2011, 17:30

Hehe...

Zone-level might work better, but we already have one in place... but it seems this methodology is on the right track :)

Question is how to now optimize :)
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 18 Aug 2011, 17:33

Well, to optimize you only need to send from the webserver the essential info, like for example cmdName ("addBuddy", "removeBuddy", etc) and buddyName ("rjgtav", "omnivibe", etc). And you would only have 1 function to handle all the webserver requests.

After this, i think the only optimization may be the protocol used to send the data between the webserver and the server.
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
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 18 Aug 2011, 17:36

It looks like the way to communicate between jetty and sfs hasnt changed from sfs1x and sfs2x:

viewtopic.php?t=10332&highlight=jetty+extension
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
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 18 Aug 2011, 18:08

interesting... our current processing is all happening in .NET... so it seems like we'll need to go

browser -> IIS -> service request at some other port where Jetty sits -> SFS (via Jetty sharing SFS extensions)

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

Postby rjgtav » 18 Aug 2011, 18:55

Probably yes. I dont know if there's a better way
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
omnivibe
Posts: 91
Joined: 05 Oct 2010, 09:23
Contact:

Postby omnivibe » 19 Aug 2011, 05:09

Thanks for all your feedback :)

Return to “SFS2X ActionScript 3 API”

Who is online

Users browsing this forum: No registered users and 12 guests