angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

[Feature Angular 1.3] Support for websockets

Open Thomasdezeeuw opened this issue 12 years ago • 55 comments

Would be great if Angular had an service that provides websockets support.

Thomasdezeeuw avatar Dec 14 '13 22:12 Thomasdezeeuw

+1

konsultaner avatar Dec 15 '13 14:12 konsultaner

+1

cheahkhing avatar Dec 15 '13 15:12 cheahkhing

+1 if it is as a separate module

capaj avatar Dec 15 '13 19:12 capaj

+1

NathanielAJohnson avatar Dec 16 '13 04:12 NathanielAJohnson

+1

marcalj avatar Dec 16 '13 11:12 marcalj

+1

warnerandy avatar Dec 19 '13 23:12 warnerandy

+1

gauravmeena0708 avatar Dec 20 '13 05:12 gauravmeena0708

-1 All you need to do is wrap Socket.IO or SockJS in a service. Not sure why this needs to be core functionality. There are so many other improvements that need to be made that far outweigh a redundant WebSocket wrapper service, and the community doesn't have infinite resources.

thebigredgeek avatar Dec 20 '13 06:12 thebigredgeek

^ I agree with you, I think most of us don't want it as a core service but as a component/wrapper only it would be waste of socket.IO if someone write it from scratch

gauravmeena0708 avatar Dec 20 '13 07:12 gauravmeena0708

I think it should be an separate module, and get the $http out of the core aswell. Then you can just have a nice wrapper around ajax and websockets.

Thomasdezeeuw avatar Dec 20 '13 12:12 Thomasdezeeuw

+1

aroop avatar Dec 20 '13 16:12 aroop

I think wrapping it in your own service + sockets.io isn't "that" hard, and allows the angular team to focus on other stuff.

CWSpear avatar Dec 20 '13 16:12 CWSpear

I think you are probably right ... it just need a proper example of good integration of socket.io not a full featured core component

gauravmeena0708 avatar Dec 20 '13 17:12 gauravmeena0708

http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets/ worked for me pretty well.

joshkurz avatar Dec 20 '13 17:12 joshkurz

Was it a waste of time for the angular team to wrap the XMLHttpRequest? Why not just ask the community to wrap $.ajax or any of the other XMLHttpRequest wrappers out there. I understand the counter points to this feature but in all honesty if the feature is as simple as the opponents are saying then whats the harm in adding it in (and not wrapping a current implementation).

warnerandy avatar Dec 20 '13 17:12 warnerandy

XHR has matured a lot since its inception, despite still being a bit weird in a few ways... But WebSockets aren't totally there yet. We still support IE9 (although maybe it will be phased out sooner than IE8) which doesn't implement sockets at all... And then you end up writing alternative transports (such as XHR longpolling) so that all of the supported browsers are covered... This is a lot of work, which isn't needed by everybody, or even most people.

I'm with you in that websockets are super cool, but alternative libraries like socket.io do a much better job of covering all of the alternative transports that you might need to target a broad range of browsers/devices. In the future, I'm sure we'd love to have builtin (and very simple) WebRTC services and WebSockets services and all that jazz, but it's probably not going to be reasonable for a while yet.

That said, there are plenty of third-party modules incorporating this stuff (@joshkurz gave an example above), so given the availability of these, is it really needed in core just yet?

caitp avatar Dec 20 '13 17:12 caitp

I don't disagree, the websocket technology is still young, and there's a lot of work to get the web ready for websockets. However you are the first one to bring up this valid point :) The previous nay-sayers simply argued against redundancy of socket and the like (which i was trying to point out as a silly argument).

However a simplistic socket implementation (not worrying about fallback to longpulling) would be enough for now. Since I would assume if you are going to use websockets (and not socket or atmosphere or anything else) you should know what you are doing and want to handle the failovers on your own. My current solution is to wrap atmosphereJS and it works quite nicely. but who is to say it wouldnt be nice to have a simple core implementation.

warnerandy avatar Dec 20 '13 17:12 warnerandy

+1

mauricedb avatar Dec 20 '13 18:12 mauricedb

+1

standuprey avatar Dec 20 '13 20:12 standuprey

:+1:

alonisser avatar Dec 21 '13 10:12 alonisser