problems about remoting singleton

G

Guest

we know that if the type is registered as singleton in the host side, then
all the remoting clients share one object, like:
host:
=====
TcpServerChannel chn = new TcpServerChannel(9999);
ChannelServices.RegisterChannel(chn,true);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(SomeClass),
"someclass",WellKnownObjectMode.SingleCall);
========

client:
===========
SomeClass a = (SomeClass)Activator.GetObject(typeof(SomeClass),
@"tcp://172.16.64.190:9999/mul");
===========

now that all the remoting clients share one object, is there anyway i can
capture this object shared by the client? or can i just "new" an object and
then register this very object instead of the type of it on the host side so
i can control the state and behavior of it.

thankx
 
G

Guest

Not entirely sure about the answer to your question (although I will look),
however, the line:
RemotingConfiguration.RegisterWellKnownServiceType(typeof(SomeClass),
"someclass",WellKnownObjectMode.SingleCall);
doesnt make a singleton. The WellKnownObjectMode.SingleCall means one per
client. WellKnownObjectMode.Singleton means one shared object
 
G

Guest

I cant see anything from the framework to do this but one easy answer is to
have a static property on the server type which each instance sets to itself
on activation. For a singleton, there should only be one so it should work
nicely. Then you can access this property on the server. You will need to
ensure thread safety on all methods and properties though.
 
G

Guest

1.do you mean that i design the server type as a singleton (using the
singleton pattern as showned in the book of GOF)?
2.it is really my stupid mistake the the codes given previous, i actually
meant WellKnownObjectMode.Singleton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top