|
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
Last edited by zhangweiit; 03-01-2010 at 06:58 AM..
Reason: edit code
|