This is a mirror of official site: http://jasper-net.blogspot.com/

WCF service that will push content into a Silverlight application [Push notification]

| Sunday, May 1, 2011
Introduction

Push notification is a term that has been around a lot. Almost every SmartPhone manufactured has an option for enabling push notification. The word 'PUSH' is a contrast to 'PULL'. It means rather than pulling the content from the server or requesting from the server, the server pushes the content or sends the response as soon as an update is available. On mobiles, this technology is a great battery saver. In web technologies, it saves a lot of server request traffic. There are tons of articles available on the internet about implementing this technique, but I found MSDN the best. Therefore, I went ahead and made the MSDN tutorial even easier for beginners. Remember, this is beginners article, but the idea of implementing a real life application stays around this. You can recode it as best as you can.

Over here, we are going to see a Silverlight application requesting for stock prices of Yahoo! The server will start pushing the latest stock prices. The stock prices are random numbers. The application is based on some assumptions.

Background

As a newbie, you must be aware of WCF, basic Silverlight, and terms like Push notification. Please refer to Wikipedia for the definitions.

Using the code

I have used .NET Framework 4.0 to develop the example. You might have to change some code if you are using an earlier version.

Go to the new project and create a WCF Service Application. The first thing to add is the reference to the Polling Duplex DLL. You need to browse in your Add References window to %Program Files%\Microsoft SDKs\Silverlight\v3.0\Libraries\Server\System.ServiceModel.PollingDuplex.dll. Please look carefully, we are referencing the polling duplex DLL from the libraries\server folder.
Right click the project and add a new item 'Interface'. You can name it IService1.cs.
You must include these in the header area--> using System.ServiceModel; and using System.ServiceModel.Web;.
Copy-paste the following code. Basically, we have defined two interfaces within this interface. IsOneWay=true is a messaging pattern which means 'call and forget' in contrast to 'request-response'.

Read more: Codeproject

Posted via email from Jasper-net

0 comments: