![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello! I have a remoting server which exposes a Singleton object to a client. The client can call methods on the object without any problem. Now, I'm trying to let the client modify the exposed object. My question is: How would the server be able to load the exposed object an retrieve the value set by the client? I'm asking because there is no mention of the currently exposed instance of the class in the server code. Or how do I expose a named instance of an abject to my clients? (having a named instance would probably solve my problem) Thanks |
#3
| |||
| |||
|
|
Greetings! You asked exactly the same question I asked two threads below. I also posed the question to a co-worker who is more familiar with the possibilities of the .Net framework than I am. He proposed a method based on a separate class that can send a copy of the remoted object back to the server. I don't understand it, but it works. I am attaching a zip file containing a sample based on the Clock1 example in chapter 15 of "Programming Microsoft .Net" by Jeff Prosise. Just change your IP address and port numbers as desired, and things should work. If somebody would kindly explain why twice as many clock objects are created as I need, I'd greatly appreciate it. The client creates two of them, numbered 1 and 3. I don't understand why clocks 2 and 4 are being created. Rob |
#4
| |||
| |||
|
#5
| |||
| |||
|
#6
| |||
| |||
|
#7
| |||
| |||
|
|
Ken, I tried using RemotingServices.Marshal() as you suggested. It worked! In the server, I replaced: RemotingConfiguration.RegisterWellKnownServiceType (typeof (Clock), "Clock", WellKnownObjectMode.SingleCall); with: Clock serverClock = new Clock(); serverClock.Number = 99; ObjRef serverClockRef = RemotingServices.Marshal(serverClock, "ServerClockURI"); In the client, I replaced: RemotingConfiguration.RegisterWellKnownClientType (typeof (Clock), "tcp://localhost:1234/Clock"); with: RemotingConfiguration.RegisterWellKnownClientType (typeof (Clock), "tcp://192.168.1.29:1234/ServerClockURI"); The client application happily reported that it was using clock number 99. Next question: For my application as it is currently designed, this will suffice, since there will never be more than a single client communicating with a server. But what happens when we decide that a single server application will manage an unknown number of printers? In that case, I would want my objects to be client-activated, but I still want the server to know what objects it created. How do I do that? Thanks again! Rob |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |