Click to See Complete Forum and Search --> : [RESOLVED] Can a WCF service initiate communications to the client?
Hamish
Feb 18th, 2009, 04:58 AM
I watched the first few videos at channel 9 (http://social.msdn.microsoft.com/content/en-us/msft/netframework/wcf/Screencasts), and was wondering about this:
For example, if I'm building something like a chat program where I want to support multiple participants, one of the participants will enter a message and submit it to the service. It would then need to relay the message to all the clients. Is there any way (besides having the client periodically update or building a WCF service into your client that can trigger the update) the service can send an update to the client?
Lightning
Feb 18th, 2009, 05:31 AM
Yes WCF can do that, it is called WCF callback (a simple example (http://dotnetaddict.dotnetdevelopersjournal.com/wcf_alarmclock.htm))
Hamish
Feb 18th, 2009, 05:42 AM
Hmmm, not that simple I would say, but I got the idea. (I think :))
Lightning
Feb 18th, 2009, 05:44 AM
A complicated thing can't be explained too easy
Hamish
Feb 18th, 2009, 05:47 AM
True!
mendhak
Feb 18th, 2009, 08:00 AM
When it comes to chat clients, you run the risk of non-availability and I don't think a callback is the best solution for this scenario unless you're prepared to set up the housekeeping code to handle lost connections, etc. Most chat services on the web operate with the client polling the service at regular intervals. An intranet environment or a small network could work well with a callback.
chris128
Feb 18th, 2009, 08:35 AM
I know this isnt a solution but I'm curious as to why you really need a service for a chat client - why cant each chat client just have the ability to send and recieve messages and when you want to send a message to multiple recipients you just have the client do the sending to each recipient, instead of passing it to the service for the service to then pass to each recipient?
I guess what I'm asking is - what advantage do you get out of using a central service to pass things around in this scenario?
Hamish
Feb 18th, 2009, 10:34 AM
It was just a hypothetical example. No particular reason....
I do have a plan for a project where I would do more with the application that includes the chat service than just forward chat messages. The chat functionality would be just one of the components, and I want to make sure that the application hosting the central service gets the messages, even if other connected clients don't.
mendhak
Feb 18th, 2009, 12:12 PM
To answer chris - a WCF service is useful here because you can use an MSMQ binding and let MSMQ handle the message queue with guarantees and reliability.
vbNeo
Feb 20th, 2009, 03:16 AM
To answer chris - a WCF service is useful here because you can use an MSMQ binding and let MSMQ handle the message queue with guarantees and reliability.
WCF is also great for handling security.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.