[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Phil Greg

11/4/2004 8:07:00 PM

Alright, I've been at this for a couple of days now, and thanks to the
helpful people on this forum, I've finally got a C++ project working pretty
well.

There's still something I wonder, though. Here's how my stuff works:

When a client is started, it calls up a method called RegisterWithServer on
the server, which returns the 0 based index of the newly register instance.
When that instance wants to call up a certain function, it needs to provide
its instance number so it can ben identified. What I want to know is: is
there any way the server can know who's calling its functions (maybe by
checking which port the message is coming from), without the client having to
provide its instance number?
4 Answers

Ken Kolda

11/4/2004 8:12:00 PM

0

Here's how I do it: instead of returning a number to the client, return an
instance of a CAO (e.g. a Session object). This CAO will hold some sort of
identifying information for the client such as the index you referred to.
Then move all of your server's methods that require knowledge of the
client's identity to be methods on the CAO. When your client invokes a
method, the object through which it is invoked provides the context/identity
for the call.

Ken


"Phil Greg" <PhilGreg@discussions.microsoft.com> wrote in message
news:495A3FE1-31F5-4BE8-976D-A47ED03EA694@microsoft.com...
> Alright, I've been at this for a couple of days now, and thanks to the
> helpful people on this forum, I've finally got a C++ project working
pretty
> well.
>
> There's still something I wonder, though. Here's how my stuff works:
>
> When a client is started, it calls up a method called RegisterWithServer
on
> the server, which returns the 0 based index of the newly register
instance.
> When that instance wants to call up a certain function, it needs to
provide
> its instance number so it can ben identified. What I want to know is: is
> there any way the server can know who's calling its functions (maybe by
> checking which port the message is coming from), without the client having
to
> provide its instance number?


Phil Greg

11/5/2004 1:48:00 PM

0

This sounds good, but since a CAO is a client activated object, how can it be
returned by a Server activated one?

"Ken Kolda" wrote:

> Here's how I do it: instead of returning a number to the client, return an
> instance of a CAO (e.g. a Session object). This CAO will hold some sort of
> identifying information for the client such as the index you referred to.
> Then move all of your server's methods that require knowledge of the
> client's identity to be methods on the CAO. When your client invokes a
> method, the object through which it is invoked provides the context/identity
> for the call.
>
> Ken
>
>
> "Phil Greg" <PhilGreg@discussions.microsoft.com> wrote in message
> news:495A3FE1-31F5-4BE8-976D-A47ED03EA694@microsoft.com...
> > Alright, I've been at this for a couple of days now, and thanks to the
> > helpful people on this forum, I've finally got a C++ project working
> pretty
> > well.
> >
> > There's still something I wonder, though. Here's how my stuff works:
> >
> > When a client is started, it calls up a method called RegisterWithServer
> on
> > the server, which returns the 0 based index of the newly register
> instance.
> > When that instance wants to call up a certain function, it needs to
> provide
> > its instance number so it can ben identified. What I want to know is: is
> > there any way the server can know who's calling its functions (maybe by
> > checking which port the message is coming from), without the client having
> to
> > provide its instance number?
>
>
>

Robert Jordan

11/5/2004 2:42:00 PM

0

Hi Phil,

> This sounds good, but since a CAO is a client activated object, how can it be
> returned by a Server activated one?

Ken probably meant a server activate MBRO, something like that:

class Server : MBRO, IServer {

public ISession Login(credentials) {
return new Session(credentials);
}

}

class Session : MBRO, ISession {
public void DoSomethingInSessionContext()
}

You may also have a look at

System.Runtime.Remoting.Messaging.CallContext

bye
Rob

Phil Greg

11/5/2004 3:17:00 PM

0

Ok, I get it... this is a good idea, I'll try that out.
Thanks alot guys!

"Robert Jordan" wrote:

> Hi Phil,
>
> > This sounds good, but since a CAO is a client activated object, how can it be
> > returned by a Server activated one?
>
> Ken probably meant a server activate MBRO, something like that:
>
> class Server : MBRO, IServer {
>
> public ISession Login(credentials) {
> return new Session(credentials);
> }
>
> }
>
> class Session : MBRO, ISession {
> public void DoSomethingInSessionContext()
> }
>
> You may also have a look at
>
> System.Runtime.Remoting.Messaging.CallContext
>
> bye
> Rob
>