angularjs - Terminating unused http connections that are a result of img ng-src -
i developing ios , android app (using ionic/angular)
i have following situation:
i have view this:
<div ng-repeat="monitor in monitors"> <img ng-src = 'http://myserver.com/cgi-bin/videofeed?id={{monitor}}' /> </div>
each monitor ip camera , doing here transmitting live feed continuous jpg images (multipart/mime).
what therefore happens img tag keeps showing new images continuously making live video feed
the problem facing when exit view, looks angular still keeps http connection open , server keeps connection open on side result. server launches instance of 'videofeed' per connection, , can see instances don't go away long after (15-20 minutes) exit view.
is there possible way clear out these connections forcibly client?
i searched in other such questions , talk http timeouts - not relevant in case, continuously updating image feed 1 image tag , time needs abort when exit view.
thanks
i have theory no idea if work. guessing long url pointed @ image , image being updated connection stay open, or re-open when image changes. how when user leaves state remove list dom using ng-if.
so here how achieved.
in controller:
$scope.$on('$ionicview.beforeenter', function(){ $scope.inview = true; }) $scope.$on('$ionicview.beforeleave', function(){ $scope.inview = false; })
in html:
<div ng-repeat="monitor in monitors" ng-if="inview"> <img ng-src = 'http://myserver.com/cgi-bin/videofeed?id={{monitor}}' /> </div>
can give try , let me know happens.
Comments
Post a Comment