tags:

views:

1556

answers:

6

Hi All,

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.

A: 

Silverlight is the natural choice for a WCF chat application, since you can build a richer User Interface and most importantly you interact directly with the WCF services. If you choose Ajax, then all the client programming needs to be done in Javascript. You can create an Ajax enabled WCF service, but in reality you need to talk with it through a proxy. This is similar to a JSON Rest like service and doesn't offer the full potential of WCF technology (chaining callbacks for example).

An alternative to WCF is to implement simple HTTP services (using ASP.NET MVC for example) and connect to them with a javascript library like jQuery. Of course polling is necessary, but this is what most web sites in cases like this are doing anyway. The solution has the advantage of being cross-platform, but it will probably need more time to develop and can't have as rich interface as the Silverlight none.

kgiannakakis
Thanks, so is there any advantage to using Silverlight over ASP.NET in regards to WCF functionality or is it primarily due to UI? Also, do callbacks work over an HTTP binding (If User A writes a chat message, a callback be fired to update other Users Chat window), will that work properly or is there still a need to poll a server every "x" seconds to see if there are new messages?
Sean
It isn't only the UI. As far as I know you can't do what you are describing with an Ajax enabled WCF service. Polling will be necessary.
kgiannakakis
A: 

I don't know about Silverlight, but for regular AJAX I've found handling things myself with an ASP.NET MVC controller to be much easier to work with.

orip
A: 

Check out the below link - this should be a nice article to start building chat application using WCF and WPF. Very Simple and easy to learn basic things.

http://www.codeproject.com/KB/WCF/WCFWPFChat.aspx

You can find the Attached Demo application along with Source code in the above article.

Edit:

For chat application TCP Binding is the best option than HTTP Binding.

kindly refer this --> http://www.codeproject.com/KB/WCF/HttpBinding.aspx

solairaja
Thanks solairaja. I have read through that article and there is no doubt I will be referring to it over and over again. My main question is how this would work over one of the http bindings, the author is using a tcp binding. Do you see any issues over http?
Sean
Thanks solairaja for the link, it looks like a really great example.
smaclell
check the EDIT Section for the HTTP Binding.
solairaja
This example will never suit for ASP.net. It might be misleading if you have Asp.net at your client end. Duplex calls wont work with ASP.NET clients.
NLV
+1  A: 

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.

smaclell
+4  A: 

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

Hope this helps

Cheers

RameshVel

Ramesh Vel
Hi Ramesh, thanks for the detail. Do you know if wsDualHttpBinding can be used for an ASP.NET application, or only SL supports Duplex services?
Sean
The duplex could potentially be used on the ASP.NET server side only but not directly from the client. Have fun and good luck.
smaclell
@Sean, as smallclell said we cant invoke the WCF from client side AJAX (cant invoke from js). so the better approach is COMET if you go ahead with asp.net. or WCF Duplex is better if you wanted to go ahead with SL.. check out the same topic here in SO http://stackoverflow.com/questions/1066336/wcf-asp-net-duplex-support-using-ajax
Ramesh Vel
WCF service service can be consumed from the client side using JQuery - http://johnnliu.spaces.live.com/blog/cns!90A843AB92E99F!395.entry
NLV
A: 

Hello everyone,

I'm developing a chat application with WCF. I have a win app running at the moment. But what i want to do is to communicate between win client and web client -aspnet-. The major parts of the app are completed but when opening a channel to web, it comes up with the following error: ".."

System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications.

Dou you have any idea to solve this problem

Sercan