0

I'm wondering how websites like http://www.eztrader.com/Trading.aspx stream prices to users. I know I could set an ajax call with a timeout to request the price from the server every 2 or 3 seconds, but is there a more efficient way of doing this? I'm using .net mvc 4.0 on the back-end.

tereško
  • 58,060
  • 25
  • 98
  • 150
valen
  • 807
  • 1
  • 16
  • 43

2 Answers2

4

You can try SignalR. It's a .NET library designed for this kind of real-time functionality.

Matthew Flaschen
  • 278,309
  • 50
  • 514
  • 539
  • 2
    FYI, SignalR is based on HTML5 WebSockets. It could be more efficient to use WebSockets directly. Furthermore, since only the server is sending updates (i.e. since you don't need bimodal communication), it might be *MUCH* more efficient to use [SSEs](http://www.html5rocks.com/en/tutorials/eventsource/basics/) instead. Please consider all the alternatives. IMHO... – paulsm4 Apr 08 '13 at 05:16
  • @paulsm4: I wouldn't use websockets directly. SignalR will automatically use web sockets, SSE or long polling depending on what's available. – Wim Coenen Apr 08 '13 at 07:45
  • @Wim Coenen - frankly, I wouldn't use either Websockets or SignalR in this case. My vote is for SSE. But in general - especially if the problem is simple enough, and/or efficiency is a concern, I would much prefer to go for the simple, lightweight approach instead of bringing in the heft and complexity of an additional library. IMHO... – paulsm4 Apr 08 '13 at 07:59
0

thanks ,right one by @Matthew Flaschen

thanks for the link i also searched it and found more interesting

http://www.asp.net/signalr/overview/introduction/what-is-signalr

http://blog.pluralsight.com/2013/03/20/new-course-introducing-asp-net-signalr-push-services-with-hubs/

internals-in
  • 4,798
  • 2
  • 21
  • 38