rover2341
Is riding a roller coaster...Wee!
- Reaction score
- 113
This is for learning purposes I don't have a project i am working on.
Lets suppose you have a webpage, that you want some graphs or data to update in real time, or worse case 5 sec per update (But doesn't hurt if its faster, user may be more happy) and would allow more options in the future.
Whats Important to me
Pooling - Ajax request on a timer, that ask server for info and sends any info it needs.
The Best thing about this technique is its super simple requires no work on the server side.
Long Pooling - Ajax Request, but Server waits to return data to the user intill i has data ready to return. so keeps request open.
Requires some sever coding, to handle this, and ajax call in javascrpit. Faster then pooling, less requests sent, But if user wants to send data in, it needs to do it separately, from ajax call, else you would be waiting for the server to get its data ready before you can tell it you did something else.
SSE (Server Sent Events) Or a tech like this (Comet, forever frame) - users sends ajax request to server, and server gives data back when it wants, and never closes the msg. requires a ect coding on both sides. if user wants to send it needs to send it separately (I believe).
Faster, then long pooling, only one connection, to get data, aside from ect coding on both sides to handle this i read its often used for things like stocks.
Web Sockets - Fastest, requires coding and many requirements on both sides. In today's world you wont have 98% of your users working with this, as it can be blocked by many things including firewalls, or just not supported (cell phone, ect).
SignalR - Microsoft's support. Fairly new. It requires code on the server and ajax calls and javascrpit includes. But uses websockets, foreverFrame, seversentEvents, longpolling. it trys the fastest but then falls back on the next one if it fails. It handles channels and has a fuction class, that you can use. Makes it simple to send to who you want or everyone. But prehaps the most overhead and requirements.
I think this is what i want to use, for most things future... unless i find somthing better.
It may be over kill on some projects but as a project gets larger it makes more sense. Its pretty much the only way i can use websockets with out coding a fall back system my self. I read it still has some bugs in it, as its fairly new. (Another note: is i can use it to connect to my unity, wpf projects , windows phone projects quite easily as well. and the server side stays the same)
At work we are just using polling as its fast enoufe, and works.
But for my own projects unless pooling is more then fast enough, i think i would use signalR over any of the other methods. But I would like to know of other ways, and what you guys think, and what you would use your self.
What are some good techniques for doing this, and why?
why shouldnt i use SignalR?
I used this a one of my sources of info to understand ways of doing this. (and for the images)
http://stackoverflow.com/questions/...g-websockets-server-sent-events-sse-and-comet
Lets suppose you have a webpage, that you want some graphs or data to update in real time, or worse case 5 sec per update (But doesn't hurt if its faster, user may be more happy) and would allow more options in the future.
Whats Important to me
- Simple (or Straight forward, less requirements)
- Works in all situations, assuming they can access a web page with a internet connection. (Meaning I don't want this to work for 50% of my users, at least 98%)
- Speed Is Nice, But not super important, the more speed the more flexibility I have.
- Flexible
Pooling - Ajax request on a timer, that ask server for info and sends any info it needs.
The Best thing about this technique is its super simple requires no work on the server side.
Long Pooling - Ajax Request, but Server waits to return data to the user intill i has data ready to return. so keeps request open.
Requires some sever coding, to handle this, and ajax call in javascrpit. Faster then pooling, less requests sent, But if user wants to send data in, it needs to do it separately, from ajax call, else you would be waiting for the server to get its data ready before you can tell it you did something else.
SSE (Server Sent Events) Or a tech like this (Comet, forever frame) - users sends ajax request to server, and server gives data back when it wants, and never closes the msg. requires a ect coding on both sides. if user wants to send it needs to send it separately (I believe).
Faster, then long pooling, only one connection, to get data, aside from ect coding on both sides to handle this i read its often used for things like stocks.
Web Sockets - Fastest, requires coding and many requirements on both sides. In today's world you wont have 98% of your users working with this, as it can be blocked by many things including firewalls, or just not supported (cell phone, ect).
SignalR - Microsoft's support. Fairly new. It requires code on the server and ajax calls and javascrpit includes. But uses websockets, foreverFrame, seversentEvents, longpolling. it trys the fastest but then falls back on the next one if it fails. It handles channels and has a fuction class, that you can use. Makes it simple to send to who you want or everyone. But prehaps the most overhead and requirements.
I think this is what i want to use, for most things future... unless i find somthing better.
It may be over kill on some projects but as a project gets larger it makes more sense. Its pretty much the only way i can use websockets with out coding a fall back system my self. I read it still has some bugs in it, as its fairly new. (Another note: is i can use it to connect to my unity, wpf projects , windows phone projects quite easily as well. and the server side stays the same)
At work we are just using polling as its fast enoufe, and works.
But for my own projects unless pooling is more then fast enough, i think i would use signalR over any of the other methods. But I would like to know of other ways, and what you guys think, and what you would use your self.
What are some good techniques for doing this, and why?
why shouldnt i use SignalR?
I used this a one of my sources of info to understand ways of doing this. (and for the images)
http://stackoverflow.com/questions/...g-websockets-server-sent-events-sse-and-comet