1

I'm about to start to develop and application in C# but I realized that I haven't the enough knowledge to develop it yet :S. The thing's that I need to find out a way to let the Web server comunicate with my application, i.e., in short, is there a way to let the web server (not the Client which is the trivial case) send a messege to a Client application?

I know that I way to solve it's to make Client applications periodically send messages to the web server but that's not what I want 'cause polling generates overhead

Sorry about my english! I'm not a native speaker.

Thanks in advance!

Solid Snake
  • 130
  • 1
  • 7
  • There are ways. Are you currently using any client to server communication? – Oskar Kjellin Aug 24 '11 at 21:43
  • Which server technology are you using? There is a convenient method if you are using the Google App Engine for example. – Philipp Schmid Aug 24 '11 at 21:46
  • @Philipp: Does this work with C#? Check the tags... – Merlyn Morgan-Graham Oct 30 '11 at 04:24
  • You could try WCF streaming to stream out messages to the client. They'll call the stream on one thread and leave it running. When a message is sent and the streaming is complete, they could use binary serialization to turn it into the known specific message type. Then they'll just re-open the stream. I have no idea on the overhead of keeping a stream open, or of recreating it, but this sounds like it could work for the purpose of infrequent and small size messages. You could also try SAX-style XML streaming/eventing this way, and leave that WCF stream open... – Merlyn Morgan-Graham Oct 30 '11 at 04:35

3 Answers3

2

Generally this type of interaction is achieved with Comet or WebSockets - I'm not sure how your app will be communicating with the server, but I would bet you can do what you're trying to do using one of those.

Jesse
  • 10,370
  • 10
  • 62
  • 81
  • [WebSockets](http://en.wikipedia.org/wiki/WebSockets) isn't a widely adopted standard yet. And [Comet](http://en.wikipedia.org/wiki/Comet_(programming)) isn't a specific technology, though the technique could be useful here. +1 for Comet – Merlyn Morgan-Graham Oct 30 '11 at 04:15
  • For sure, although there are ways to fake web sockets on older browsers (typically employing flash). Socket.io is a great example of this. – Jesse Nov 01 '11 at 17:07
2

You could implement a WCF service in your client that could listen for a connection from the server (or anything else). The server can communicate with the client as easy as calling the API.

Getting started with WCF is really easy using the wizards in VS.

Here is a link that talks about using WCF with ASP, but it can be used outside of asp as well.

AdamC
  • 16,087
  • 8
  • 51
  • 67
  • Thank you so much for helping me Adam! yours' a great answer. I think WCF's a great point to start with. "as easy as calling the API" Awesome! – Solid Snake Aug 24 '11 at 22:13
0

It seems like you meant "push" messaging, the challenge around this is for the server to keep track of the lost of clients and manage who should recieve which message.

If you want to get it done with minimal overhead you can check out the Amazon Simple Notification Service.

SNS is a cloud-based messaging and notification service hosted and managed for you, SNS is based on a topic/subscriber model and you set it up via a few simple API calls, it is metered but quite inexpensive for the most part.

edit: For C# Libraries and frameworks to do it yourself, I am not an expert in the C# world so I think other answerers will know it better.

Disclosure: I work at amazon so I am naturally inclined to like their product

Desmond Zhou
  • 1,369
  • 1
  • 11
  • 18
  • From the beginning of their question, I think their technology stack is: "C#" and "about to start to develop an application". Microsoft would probably push IIS/WCF. Is there a different stack he should check out before going that route? – Merlyn Morgan-Graham Oct 30 '11 at 04:21
  • Ah I see, sorry missed the obvious! I am not familiar with the world of C# so I guess someone more qualified can answer it. – Desmond Zhou Oct 30 '11 at 04:27