Custom room events?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

User avatar
xLite
Posts: 106
Joined: 05 May 2010, 12:42

Postby xLite » 08 Mar 2011, 18:01

Can you elaborate on how to take advantage of SFS and it's thread pools? Again, it's not mediums like Room Variables I am seeking help on it's how to handle incoming event requests etc.

At the moment the best I can come up with is an If/Else statement in my handleClientRequest function.

i.e.

Code: Select all

if(open door)
{
    validate, check permissions, update room variable
}
else if(turns on lights)
{
    validate, check permissions, update room variable
}


Although as you can tell, this idea wouldn't work if thousands of people were sending open door and turn on lights requests at the same time. So I need to know how to properly "multithread" this scenario so that everything is efficient, clean and fast.


Thank you everyone for your help so far :)
tchen
Posts: 191
Joined: 11 Dec 2010, 14:14

Postby tchen » 09 Mar 2011, 23:22

I think you keep coming to this with some preconceptions on threading. The handleClientRequest you have is just fine.

Let's follow a request as it comes over the network.

1. The client initiates an extension request
2. The request is packaged and sent over the network
3. At the server, the packet is buffered at the socket and subsequently read in by the SFS Socket Reader.
4. The task to actually do something is inserted into the ExtensionManager's thread pool's queue.
5. One of the ExtensionManager's thread pool's thread comes by and picks up the task which includes the message, the sender, etc.
6. It invokes the handleClientRequest.

Steps 4-6 are all threaded and scale pretty well. Obviously, don't do things in handleClientRequest that'll block the few threads the pool uses (eg: sleeps and while loops).

If you need to delay a task or something needs to a take a long time, you use the TaskScheduler at the zone level.
User avatar
xLite
Posts: 106
Joined: 05 May 2010, 12:42

Re: Custom room events?

Postby xLite » 27 Nov 2012, 00:35

Sorry for such a late reply but I felt like I need to give you guys a huge thanks! In the time I've been away, I've learnt a great deal. I successfully created and hosted 20 player beta isometric multiplayer online chat community session on a client and SmartFoxServer extension that I coded myself.

Ever since then I've been working with an awesome team to crank out an official V1 grade release on the awesome SFS2X software using the Starling AS3 framework to utilise hardware acceleration client-side. It's going extremely well and coming back to this thread, I understand your comments whole-heartedly and really appreciate the information. I can't wait to share what my team and I have been working on and you are partly to thank so thank you!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 52 guests