Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR for .net and Observer Pattern

So far I had gone through lots of articles explaining SignalR.

Searching turns up a simple definition: SignalR can be used to develop real time web application

As per wiki : Real Time Web Application is a set of technologies and practices that enable users to receive information as soon as it is published by its authors, rather than requiring that they or their software check a source periodically for updates.

It seems that SignalR is similar to observer/publisher & Subscriber pattern, where the client subscribes to the server and Server sends the notification to all the client if the event occurs.

So my query is : 1) Is that SignalR is based on Messaging Pattern (i.e. observer/publisher & subscriber)?

2) If yes, then why another messaging pattern SignalR when we already have existing one.

3) What are the advantages of SignalR over messaging pattern (observer/publisher & subscriber)

like image 236
Anil Purswani Avatar asked Apr 19 '12 11:04

Anil Purswani


1 Answers

This question hasn't been answered for almost 4 years! SignalR is a Microsoft's recommend solution for real time application development. Http request/response model requires client to invoke the server to get a response from server. But SignalR allows the server to push messages to clients without client frequently polling the server.

Answer1. Yes, this has observer/subscriber pattern implementation. Client needs to first subscribe to server event. Server then broadcasts (or it can send messages to each client) to client.

Answer 2 & 3. I will be more practical for this answer, if you need to push notifications to the client (like fb notifications, eventlog etc.) this would be ideal. There is no other technology similar to SignalR in the .Net technology stack, which does this more effectively.

Refer to this Stock Market sample app how it generates server events and passes onto the client in real time. Multiplayer gaming and online chat are some other useful cases.

like image 94
Dhanuka777 Avatar answered Sep 24 '22 18:09

Dhanuka777