Wednesday, February 20, 2008

Simple remoting

I've searched the web for a good and simple remoting example. Some were good, some bad and some simply awful. The trouble with the good ones I found, was that none of them where "complete" or lacked certain features that I was in need of. So I've scanned the web, took the parts I liked and put them togheter to create a good example on which one can build a remoting solution. I'm using .net 2.0.

My goal is to create a simple chatroom solution. I don't want the clients to be polling for messages. I want the messages to be distributed to them. For this project i have created three solutions with VS2005. They are called ServerSide, Mixed and ClientSide.




ServerSide:
On the server side we have the hosting server. It´s a console application. All that this app does is making other objects reachable. I´ll show you the code soon. Then we have what I call the server object. This can be whatever as long as it inherits from the marshalbyrefobject. This is the object that does the "server work". In this example the serverobject "is" the chat server.

ClientSide:
On the client side there is the ClientApplication and a client object. The client application instanciates a client object and "Attaches" it to a server object.

Mixed
For lack of a better word I call this the mixed files. Files that will be shared by the client and server side. The thing is that the server and client side are not aware of each other. What enables them to interact are interfaces. Both sides have references to these interfaces.

In my next post I´ll start to show you the server code.

No comments: