Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Chat with WCF

Tags:

asp.net

wcf

chat

I'm looking to implement a chatroom interface for an ASP.NET page. I'm in the process of learning WCF and it seems that it is appropriate for a chat application. Before I get too involved into WCF I want to be sure it is the right choice to make for developing a chat application in ASP.NET. Can anyone provide any feedback?

I found a few example applications that primarily use Silverlight with WCF for chat applications. Are there any limitations if I choose not to use Silverlight?

Also, any alternatives to WCF that I would have full control over would be very helpful. I'm aware I can use AJAX polling, feedback on advantages/disadvantaged are all appreciated. Thank you.

like image 241
Sean Avatar asked Dec 12 '09 23:12

Sean


2 Answers

You can use either Native ASP.Net approach or Silverlight approach to develop the good looking chat application.

The only concern is how your application is responsive to the end user. Here responsive means how the system let the user to feel the presense of other users and real time chat experience. This is refrenced sometime as really real time. (Like gmail & facebook webchat allows the user to see the user presense saying "user is typing or idle")

You can achive this level of realtime appearance using both these technologies. But implementation are little different.

In order to achive this, you must implement a duplex communication between the browser and server. So then server will notify the client if there is any response from other user or his presense.

In ASP.Net way:

  • This is been completely controlled by AJAX.
  • You have to simulate the Duplex communication using AJAX. By default HTTP doesnt support duplex. Its oneway. It only responses to client request. It cant directly invoke client method .
  • There are existing techniques available to achive this. One of the approach is called COMET or ReverseAJAX.
  • Its nothing but the long living AJAX calls, and will respond to the client if there is a expected event happening in server side, otherwise it stays calm. This Comet (programming) wikipedia article explains more about the approach.

In SilverLight way:

  • Silverlight gives much better User experience compared to normal HTML pages.
  • By using SL, you can make use of WCF Duplex services to implement the server push technique. As per MSDN, it says

A duplex service contract is a message exchange pattern in which both endpoints can send messages to the other independently. A duplex service, therefore, can send messages back to the client endpoint, providing event-like behavior

  • Here the nice example implementing duplex in SL.

Hope this helps

like image 182
RameshVel Avatar answered Sep 28 '22 03:09

RameshVel


Silverlight Client:

Silverlight has several advantages including UI flexibility, greater WCF control and being able the same programming language/tools on client and server. If you chose Silverlight you have more flexibility over how data is transferred to and from the server, such as what protocol to use (TCP, HTML) and how to transfer data. The UI options with Silverlight allow you create a very rich and compelling experience with the complete designer support and animations.

ASP.NET Client:

A simple HTML client may be faster to create since you would not need to learn how to use Silverlight to create the equivalent functionality. Even with just HTML, css and javascript, you can still have a very nice user experience just look at gtalk as an example. Using modern javascript libraries like jQuery make it even easier to create a complicated application quickly that is still easy to understand and maintain.

If you are looking to play around, have some fun and learn something new perhaps consider using a ASP.NET client with a basic WCF RESTful interface. You will still have alot of control and flexibily on both the client and server regarding what messages to send, how the client makes requests, caching on the server, etc. For an easy to digest post regarding RESTful WCF check out this post by Rick Strahl.

I wrote a similar type of application to perform notifications within an ASP.NET application and was waffleing between doing push vs. polling from the client (see this stack overflow question). I was inspired by this chat example which used a very simple interface and push notification for the client.

like image 35
smaclell Avatar answered Sep 28 '22 03:09

smaclell