PDA

View Full Version : Count Shared objects created on server


nthaka1
02-12-2010, 05:58 AM
Hi Experts,

I am working on a game projects right now. I have created game using Flex and FluorineFx(ASP.NET). In this I have used persistent remote shared object to share the common UI to two players. Now It can be heavy traffic on the server as there might be thousands of games running at a time. So to balance the load on the server, I want to count the shared objects created on the servers. If shared objects on the server exeeds the max limit then I will switch the requests to create sharerd object on the other server.

So for this, how can I count the shared objects created on the server. Also can I chech that the shared object is created or not on the server, I mean is there any methos which returns any flag based on the checking that shared object of perticular ID is exist or not.

I would appreciate if I will get quick reply as it is quite urgent for me.

Thanks in advance.

kev_az79
02-18-2010, 08:04 PM
I don't see how I post my question

zhangweiit
03-01-2010, 06:38 AM
i would do it like this:
on serverside , declare a class named ShareObject
it has a static member object table of type Dictionary
if u want to check if it is created ,define a id member
when the constructor is invoked ,count increase by one;


if u want shareobject to transfer between server and client
u'd better define serialize and unserialize methods
then transfer the share objects as string
and unserialize them from string

give u some code:
class ShareObject{
static Dictionary<int,ShareObject> objectTable;
int id;
public ShareObject(string data){
//if data is null,build a new one ,assign an id,and add to dictionary
//else,find id in data,check existence,and unserialize it;
}

string serialize(){...}
void unserialize(string data){...}

static int count(){...}
static bool existed(id){...}
static void add(int id,ShareObject obj){...};
static void remove(int id){...}
}

it's too simple,but just

nthaka1
03-04-2010, 10:49 AM
Hi zhangweiit,

Thanks a lot. I will implement this approach and will let you know if any problem I have.