Introduction
The application is a simple Chat server and Client, which is conversion of Java RMI chat server and client. The Java client was a Applet and present application client in WinForm.
You can find the original Java code from [Troy Downing [email protected] http://www.webcal.com/downing/ February 1997]
Technology Used
Serialization, Remoting
Serialization : Serialization is the process of converting a graph of objects, into a linear sequence of bytes. That sequence of bytes can be sent elsewhere (for example, to a remote computer) and Deserialized, thereby making a clone in that remote memory of the original graph of objects. Serialization is necessary in this application to have the state of the Remote Object on the client and server at the same time.
Remoting : Microsoft .NET Remoting provides a rich and extensible framework for objects living in different AppDomains, in different processes, and in different machines to communicate with each other seamlessly. .NET Remoting offers a very powerful yet simple programming model and runtime support for making these interactions transparent
.NET Remoting Objects
There are three types of objects that can be configured to serve as .NET remote objects. You can choose the type of object depending on the requirement of your application. This section explains these objects in detail.
"Single Call" objects service one and only one request coming in. Single call objects are useful in scenarios where the objects are required to do a finite amount of work and usually not required to store state information. Single Call objects can be configured in a load-balanced fashion. Single Call Objects cannot hold state information between method calls.
"Singleton" Objects are those objects that service multiple clients and hence share data by storing state between client invocations. They are useful in cases where data needs to be explicitly shared between clients and also where the overhead of creating and maintaining objects is substantial.
In the sample we have to use singleton because of the nature of the application.
Client Activated Objects (CAO) are server side objects that are activated on request from the client. This way of activating server objects is very similar to the classic COM coclass activation. When the client requests for a server object using "new" operator, an activation request message is sent to the remote application. The server then creates an instance of the requested class and returns an ObjRef back to the client application that invoked it. A proxy is then created on the client side using the ObjRef. The client's method calls will be executed on the proxy. Client Activated Objects can store state information between method calls for its specific client and not across different client objects. Each invocation of "new" returns a proxy to an independent instance of the server type.
Passing Objects Using .NET Remoting
In .NET Remoting, objects can be passed from one application to another in the following ways:
- As parameters in method calls
Example: public int myRemoteMethod (MyRemoteObject myObj)
- Return Value of method calls
Example: public MyRemoteObject myRemoteMethod(String myString)
- Values resulting from property or field access of a .NET component
Example: myObj.myNestedObject
For objects that are Marshal By Value (MBV), a complete copy of the object is made when the object is passed from one application to another.
Hosting .NET Remoting Objects
.NET Remoting objects can be hosted in:
Channel Services (System.Runtime.Remoting.Channels)
The .NET framework supplies the HTTP, TCP and SMTP channels but third parties can write and plug in their own channels. The HTTP and SMTP channels use SOAP by default to communicate whereas the TCP channel uses Binary payload by default.
Present Application uses TCP channel to communicate.
About the sample
Server is a console application and client is Win Form. This application uses Remoting Namespace of .NET to transfer the Server Object on wire and gets created on the Client. Remoting can be done in .NET by many means (channels), TCP channel is used in the present sample. You can use HTTP channel or SOAP to do this too.
Good luck and Enjoy C#.
Mayank GuptaPosted Jan 28, 2013, 7:36 AM
This is another error I am getting other than TCP missing reference. Error 16 The type or namespace name 'ObjectList' could not be found (are you missing a using directive or an assembly reference?) C:\Users\mayank.g\Downloads\RemotingChat\RemotingChat\ChatServerImpl.cs 13 11 RemotingChat
Mayank GuptaPosted Jan 28, 2013, 7:35 AM
Hi while executing your project on remoting chat, I am getting the following error. Pls help me to fix it. "Error 15 The type or namespace name 'TCP' does not exist in the namespace 'System.Runtime.Remoting.Channels' (are you missing an assembly reference?) C:\Users\mayank.g\Downloads\RemotingChat\RemotingChat\ChatServerImpl.cs 5 41 RemotingChat "
ahlam mohemmedPosted Aug 7, 2011, 11:24 PM
thank u very much from dreamzzzzzzzzz
ahlam mohemmedPosted Aug 7, 2011, 11:21 PM
thank u very much from dreamzzzz
Andy GrantPosted Apr 28, 2010, 11:37 PM
Hi Pramod, This is Andy here.The Chat is really a great work. I need to know if it will work in internet too. If not, can you suggest me what changes i need to do to make it work in internet?Its really urgent.Please reply me as soon as possible.My email id is [email protected]. Waiting for your reply. Thanks and Regards Andy Grant
taleb khafaeiPosted Oct 15, 2009, 3:55 AM
plz help me ? how can I run this sample?
pato dimPosted Aug 30, 2007, 9:45 AM
:P I think the best first step is a project that complies and runs smoothly