Managing multi-extension Zone

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Posts: 31
Joined: 16 Apr 2009, 11:23

Managing multi-extension Zone

Postby duke » 14 May 2009, 00:25

The questions here might be a bit vague - i'm at work so I can't look at my project to point out specifics. What is the best way to handle multiple extensions in one Zone? Right now, I have:

GameServer extensions attached to the zone. The is an mmo project in Unity.

Login manages all logins! This takes place in it's own room, and I wanted to keep it seperate so I have the future possibility of putting it in a completely different server. If a user is logged in and isn't the GameServer, ActorAdd is fired.

Manager is pretty much the central Extension, although it has little to do with, or any dependence on Login. It receives commands such as ActorAdd, ActorMove, (everything else that comes from the clients), etc. This data is then handled by seperate Java classes that aren't attached as Extensions, like Actor, Inventory, etc.

GameServer is a seperate Unity build that manages and validates stuff that SFS can't, like player collisions, etc. The GameServer manages stuff such as the GameServer request for playerlists, and stuff is passed to it such as ActorAdd, ActorMove, ActorList etc.

Now the problems I continualy run into are that often these classes can't find the current Zone or current connection. So, has anyone done something similar where they then have a central ConnectionHolder or something, that maintains the connection the Zone so it can be called from anyway? I have a static function in my Manager script that's meant to do this, but sometimes it doesn't work, and I'm sure there's a cleaner way of doing it. Should I have all my scripts attached to the zone or can I leave it like it is with the Request Handlers in the Manager/Login/GS and everything else passed to unconnected but instanced classes (they're all called as singletons at the moment).
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 18 May 2009, 08:56

You should be able to simply use "singletons" to keep state between scenes.

There are various ways to do this in Unity, but the simplest is to have a basic static class. If you look at the example codes I made, there is the smartfox.cs class that simply holds the connection.

That would be the easiest way to do it. Other ways are on the Unify wiki - a component you attach to a GO that has the "not destroyed on load" set. Effect is the same, so static class is simplest.

Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 19 May 2009, 01:06

Yeah that island demo is fantastic Thomas - thanks! I learnt about singletons and am using them successfully on both client and server. This question was more to do with serverside extensions than Unity (client). What i've got for now though, is a static GetZone function in my manager. So if i'm instancing any script or calling it's singleton instance, I just set zone to "Zone zone = Manager.GetZone();" and go from there if I need it.

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 14 guests