2

I am developing one web application in asp.net 3.5. Now I hv to do push notication with WCF. I hv successfully developed WCF with callback. Now my problem arises I cant update web application because the page lifecycle is end. So please tell me how to update web app.

For further reference plz check this link Display Messages after getting response from WCF

If it is not possible then wht method should i take. i dont want to use polling because as we except around 800-1000 users are online. so we hv to concerned about the performance as we have only single server. so plz tell me a good solution and also i want to now how google, yahoo do push notification.

Community
  • 1
  • 1
ankit Gupta
  • 313
  • 1
  • 5
  • 19
  • http://stackoverflow.com/questions/9369740/how-to-use-signalr-with-net-3-5 ok for 3.5 maybe this ? – adt Feb 13 '13 at 07:24

1 Answers1

1

Take a look at the SignalR library. It should get you started in the right direction.

However if you do want to do it yourself, the most efficient method to build this in asp.net is to use a IHttpAsyncHandler and ajax requests.

Here is a complete working project that implements this, along with ajax.

nunespascal
  • 17,584
  • 2
  • 43
  • 46
  • SignalR is not working on ASPnet 3.5 framework and this lik i already check. they also working as a polling and that i dont't want. – ankit Gupta Feb 13 '13 at 07:29
  • This is not polling. Where did you see it polling? – nunespascal Feb 13 '13 at 07:31
  • you see there is onload=setTimeOut('init();', 500) . Every 500 ms it call init() method. – ankit Gupta Feb 13 '13 at 08:21
  • How does that count as polling? A `setTimeOut` is called only once. – nunespascal Feb 13 '13 at 08:27
  • 1
    I think you confused it for `setInterval`, which called repeatedly. – nunespascal Feb 13 '13 at 08:28
  • yes it is recursive call. and i dont want that it.i just want when any client receive any response it displays on web. – ankit Gupta Feb 13 '13 at 08:31
  • 1
    It is not a recursive call. You clearly do not understand the difference between `setTimeOut` and `setInterval`. Read about them before you proceed trying to do this yourself. You can check for yourself by using a tool like fiddler. – nunespascal Feb 13 '13 at 08:41
  • can u explain how client side hook function is called – ankit Gupta Feb 13 '13 at 10:18
  • 1
    hook is used to make an async request to the server. It will wait till someone sends a message to this client. On receiving a message that is sent as the response and the callback function is called. This callback displays the message. The cycle gets complete and browser makes a new request calling hook again and waits for next message. – nunespascal Feb 13 '13 at 10:33
  • but we didn't understand from where hook function is being called on client side whenever messages is being sent. – ankit Gupta Feb 13 '13 at 10:57
  • 1
    Its called the first time on `init()` and from then on whenever you receive a reply in the callback `onreadystatechange` – nunespascal Feb 13 '13 at 11:03
  • actually i want to know when user send messages to his friend and then how server runs the hook function to display messages. – ankit Gupta Feb 13 '13 at 11:08
  • 1
    I cannot come on chat here and its quite difficult to explain all the logic in comments. An Async handler allows you to delay the response as long as you require. All clients are thus waiting in queue. Message from one, is used to create and send async result to the client for whom the message was intended. – nunespascal Feb 13 '13 at 11:43
  • Hey can u plz tell me how to send messages to multiple recipients using same code. we are able to send single user but not multiple recipients. – ankit Gupta Feb 14 '13 at 07:29
  • 2
    You have an entry for each recipient in the queue. So long as you know the sessionid of the recipient you can loop through the queue and send messages to all those recipients – nunespascal Feb 14 '13 at 09:08
  • hey can u plz tell me when we do concurrent multiple request to different users . the line "Callback(this)" it throws the error "object reference error not set to an instance of object". but when we do single request it works great. should we use lock or monitor.enter and where it should we use. – ankit Gupta Feb 15 '13 at 05:44
  • Dude, you really got to stop asking questions in comments. Put up a new question when in doubt. Its not a threading issue. When one response ends, message is sent to the user. After receiving it, clients makes new request for next message. There is a small round-trip time. During this time, you can't communicate with the client. You will have to make your messages wait for him to come back – nunespascal Feb 15 '13 at 05:52
  • I am behind a firewall that blocks chats. Sadly chat is not an option – nunespascal Feb 15 '13 at 07:02
  • actually i didn't understand why again client make new request for next message and wht exactly it changes in context and callback when making new request. and how can i wait a thread to complete new request. – ankit Gupta Feb 15 '13 at 08:27