13.07.2015 Views

Remoting in C# and .NET - The Journal of Object Technology

Remoting in C# and .NET - The Journal of Object Technology

Remoting in C# and .NET - The Journal of Object Technology

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

REMOTING IN <strong>C#</strong> AND .<strong>NET</strong>It is essential that the NameHolder class be tagged as [Serializable] <strong>in</strong> order for theSaveNamesServer to be able to marshal its <strong>in</strong>formation properly.DeploymentTo deploy this distributed application, the follow<strong>in</strong>g sequence <strong>of</strong> steps must be followed:1. Compile the server classes <strong>in</strong>to a DLL as follows:csc /target:library SaveNamesServer.cs NameHolder.cs SaveNamesServer.dll2. Compile the StartServer application as follows:csc StartServer.cs /reference:SaveNamesServer.dll -> StartServer.exe3. Compile the Client application as follows:csc Client.cs /reference:SaveNamesServer.dll -> Client.exe4. Launch the StartServer application.5. Launch the Client application.Each time the client is launched <strong>and</strong> a new name is specified on the comm<strong>and</strong> l<strong>in</strong>e, theprevious names that were entered will be output.Two GUI Clients <strong>and</strong> a Server Application<strong>The</strong> next application <strong>of</strong> <strong>Remot<strong>in</strong>g</strong> <strong>in</strong>volves two client GUI’s runn<strong>in</strong>g <strong>in</strong> separateprocesses that communicate with each other through a server object.One <strong>of</strong> the GUI applications, Client2, periodically takes the coord<strong>in</strong>ates <strong>of</strong> a square<strong>of</strong> size 50 from the server <strong>and</strong> moves a rectangle to this position (upper-left corner <strong>of</strong> therectangle). <strong>The</strong> server changes this coord<strong>in</strong>ate every two seconds so the square jumpsfrom one location to another every two seconds.<strong>The</strong> other GUI application, Client1, waits for the user to click the mouse button <strong>in</strong> apanel. A blue “X” marks the spot <strong>of</strong> the mouse click. Simultaneously, the spot at whichthe user clicked the mouse is marked with a small red “x” <strong>in</strong> Client2. <strong>The</strong> communicationis done through the server. If the Client1 user clicks with<strong>in</strong> the boundaries <strong>of</strong> the squarethat is slow<strong>in</strong>g danc<strong>in</strong>g around <strong>in</strong> Client2, a red “H” is shown <strong>in</strong> the panel <strong>of</strong> Client1. <strong>The</strong>cumulative hits <strong>and</strong> misses are also updated after each mouse click <strong>in</strong> Client1.A screenshot <strong>of</strong> both client applications runn<strong>in</strong>g <strong>and</strong> the server provid<strong>in</strong>g thecommunication channel as well as coord<strong>in</strong>ates for the mov<strong>in</strong>g square <strong>in</strong> Client2 is shownbelow.88 JOURNAL OF OBJECT TECHNOLOGY VOL. 3, NO. 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!