tag:blogger.com,1999:blog-1007651349729494127.post5012842356499523568..comments2023-07-10T08:47:58.464-07:00Comments on My online Notebook: A Better Way of Using ASP.NET SignalR With Angular JSRabi Kiranhttp://www.blogger.com/profile/14704377348226567479noreply@blogger.comBlogger30125tag:blogger.com,1999:blog-1007651349729494127.post-47800237443124842652018-12-11T03:42:29.477-08:002018-12-11T03:42:29.477-08:00nice post thanks for sharing
Education
Technolog...nice post thanks for sharing <br /><br /><a href="http://vyaparpages.com/" rel="nofollow">Education</a><br /><a href="http://vyaparpages.com/" rel="nofollow">Technology</a><br />Vicky Ramhttps://www.blogger.com/profile/09594302278614605411noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-75505086179539381952017-03-31T06:23:06.051-07:002017-03-31T06:23:06.051-07:00Thanks for the information bro/., A clear post to ...Thanks for the information bro/., A clear post to know about the subject. While it is not intended- and surely beyond the scope of this ebook - to give an introduction or even deep dive into SignalR, we need to have a look at some concepts and code in order to realize a smooth integration of SignalR and <a href="http://www.credosystemz.com/training-in-chennai/best-angularjs-training-in-chennai/" rel="nofollow">AngularJS</a>. Anonymoushttps://www.blogger.com/profile/03356446583340255405noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-23252202803230582202016-12-20T22:30:14.144-08:002016-12-20T22:30:14.144-08:00Hi Ravi
I'm using angular ,jquery and signal ...Hi Ravi <br />I'm using angular ,jquery and signal together for my project but When I try to create hub connection using angular factory approach I am seeing different connections ids getting instead of connection being singleton !!Do we have any solution or any sample code with above posted example .<br />Any help on this very much appreciated!!Anonymoushttps://www.blogger.com/profile/08277540639343479148noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-36679401132782392042016-12-02T05:40:29.009-08:002016-12-02T05:40:29.009-08:00thanks for the informative post on angularjsthanks for the informative post on <a href="http://onlineitguru.com/angularjs-online-training-placement/" rel="nofollow">angularjs </a><br />Anonymoushttps://www.blogger.com/profile/17080721738373179628noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-18541061991730530562016-05-19T10:18:48.746-07:002016-05-19T10:18:48.746-07:00For those who would like the complete html/js to m...For those who would like the complete html/js to make this sample work...this example requires the controller be added to the 'app' variable as the snippet in the article does not work as shown.<br /><br /><!DOCTYPE html><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /> <title></title><br /> <script src="Scripts/jquery-1.6.4.min.js"></script><br /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script><br /> <script src="Scripts/jquery.signalR-2.2.0.min.js"></script><br /></head><br /><body><br /> <div ng-app="app" ng-controller="SignalRAngularCtrl"><br /> <input type="button" name="GreetAll" value="GreetAll" data-ng-click="greetAll()" /><br /> <span>{{text}}</span><br /> </div><br /><br /> <script><br /> var app = angular.module('app', []);<br /> app.value('$', $);<br /> app.service('signalRSvc', function ($, $rootScope) {<br /> proxy: null;<br /> var initialize = function () {<br /> connection = $.hubConnection();<br /> this.proxy = connection.createHubProxy('myHub');<br /> connection.start();<br /> this.proxy.on('acceptGreet', function (message) {<br /> $rootScope.$emit("acceptGreet", message);<br /> });<br /> };<br /> <br /> var sendRequest = function () {<br /> this.proxy.invoke('greetAll');<br /> };<br /><br /> return {<br /> initialize: initialize,<br /> sendRequest: sendRequest<br /> }; <br /> });<br /><br /> app.controller('SignalRAngularCtrl', function ($scope, signalRSvc, $rootScope) {<br /> $scope.text = "";<br /><br /> $scope.greetAll = function () {<br /> signalRSvc.sendRequest();<br /> }<br /><br /> updateGreetingMessage = function (text) {<br /> $scope.text = text;<br /> }<br /><br /> signalRSvc.initialize();<br /><br /> $scope.$parent.$on("acceptGreet", function (e,message) {<br /> $scope.$apply(function () {<br /> updateGreetingMessage(message);<br /> });<br /> });<br /> });<br /> </script><br /></body><br /></html><br />Anonymoushttps://www.blogger.com/profile/00358671473077548779noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-80537501897972533752016-02-01T03:30:27.711-08:002016-02-01T03:30:27.711-08:00How to wirte jasmine unit test cases for signalr s...How to wirte jasmine unit test cases for signalr service?James0406https://www.blogger.com/profile/18121458903899422765noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-73946367897689158212015-09-01T04:24:24.759-07:002015-09-01T04:24:24.759-07:00I am using angularjs and Entity framework 6 with s...I am using angularjs and Entity framework 6 with signalR. The issue I facing is, the sqldependency doesn't triggers on data change. Please let me know if i need to change anything else,Anonymoushttps://www.blogger.com/profile/13924596814400484857noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-22981633514734064422015-08-30T23:34:58.370-07:002015-08-30T23:34:58.370-07:00Nice article.....Nice article.....Anonymoushttps://www.blogger.com/profile/13924596814400484857noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-74578548361312861662015-03-13T18:49:42.871-07:002015-03-13T18:49:42.871-07:00Hi Ravi,
Don't you need to declare your metho...Hi Ravi,<br /><br />Don't you need to declare your method before you start the connection ? I specifically remember that this was said during an intro to SignalR in the MS virtual academy.<br /><br />So the code should be in this order :<br /><br /> //Publishing an event when server pushes a greeting message<br /> this.proxy.on('acceptGreet', function (message) {<br /> $rootScope.$emit("acceptGreet",message);<br /> }); <br />//Starting connection<br /> connection.start();<br /><br />I personally tried your code and it didn't work until i switched these parts.Anonymoushttps://www.blogger.com/profile/08540055277226385295noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-30011928938221348602015-01-27T06:55:19.566-08:002015-01-27T06:55:19.566-08:00Sure. I am working on a sample that will cover som...Sure. I am working on a sample that will cover some of the latest updates in both technologies. Will post them in some time. Stay tuned.Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-84450410771425905932015-01-24T12:26:24.998-08:002015-01-24T12:26:24.998-08:00More samples with code.?More samples with code.?Kiquenethttps://www.blogger.com/profile/10446364197640116526noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-16565954653238788512015-01-02T20:26:17.149-08:002015-01-02T20:26:17.149-08:00Hi Ravi,
I had to make the following changes to g...Hi Ravi,<br /><br />I had to make the following changes to get this to work for cross domain (PhoneGap/ Cordova). Hope this helps others...<br /><br />.factory('SignalRSvc', function ($, $rootScope, applicationConfig) {<br /> var proxy = null;<br /> var initialize = function(){<br /> $.getScript( applicationConfig.apiUrl + 'signalr/hubs', function () {<br /> $.connection.hub.url = applicationConfig.apiUrl + 'signalr';<br /> proxy = $.connection.signalRMessageServiceProviderHub;<br /> $.connection.hub.url = applicationConfig.apiUrl + 'signalr/hubs'<br /><br /> proxy.on('acceptGreet', function (message) {<br /> $rootScope.$emit("acceptGreet",message);<br /> });<br /><br /> $.connection.hub.start().done(function () {<br /> proxy.server.greetAll();<br /> });<br /> });<br /> <br /> };<br /> var sendRequest = function () {<br /> proxy.invoke('greetAll');<br /> };<br /> return {<br /> initialize: initialize,<br /> sendRequest: sendRequest<br /> };<br /> <br /> <br />})Anonymoushttps://www.blogger.com/profile/13652088846305853690noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-62306255905747910412014-12-19T06:03:54.272-08:002014-12-19T06:03:54.272-08:00Hi,
Thanks for the update. Yes, Angular 1.3 doesn...Hi,<br /><br />Thanks for the update. Yes, Angular 1.3 doesn't allow global functions as controllers and that is the recommended way of creating a controller. I will update the post accordingly.Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-7391728182632059302014-12-19T05:01:31.928-08:002014-12-19T05:01:31.928-08:00It's ok I got it working. I had to change the ...It's ok I got it working. I had to change the controller thus:<br /><br />app.controller('StockTickerCtrl', ['$scope','stockTickerData', function ($scope, stockTickerData) { ... }]);DickPhttps://www.blogger.com/profile/17046307749798606665noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-39576629999335504562014-12-18T11:42:40.233-08:002014-12-18T11:42:40.233-08:00Hi Ravi, very useful post but I can't make thi...Hi Ravi, very useful post but I can't make this work with angular 1.3.7. I am a total angular newb. Something seems to be stopping the controller from executing. Any ideas why?DickPhttps://www.blogger.com/profile/17046307749798606665noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-32057466474467652412014-04-05T04:38:30.054-07:002014-04-05T04:38:30.054-07:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/14096769628860128924noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-2209824600578624412014-01-25T07:06:35.512-08:002014-01-25T07:06:35.512-08:00Binh,
I agree. That's a good point. It makes ...Binh,<br /><br />I agree. That's a good point. It makes sense to have all client callbacks created before starting connection as the callbacks can be invoked at any point from the server.Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-38988650428103503752014-01-25T07:01:37.323-08:002014-01-25T07:01:37.323-08:00Jason,
Yes, I used $emit as it would be listened ...Jason,<br /><br />Yes, I used $emit as it would be listened only through $rootScope. $broadcast bubbles the event to scopes at all levels, which would slow down in large scale.<br /><br />Thanks for the suggestion. I could use $rootScope.$on as well, scope.$parent is something you won't like to use in a real app. I used it to just make aware that a parent scope can be accessed using the $parent property as well.Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-36459382574486700422014-01-24T23:30:16.537-08:002014-01-24T23:30:16.537-08:00Hi, you must define functions that the hub can cal...Hi, you must define functions that the hub can call back befor connection.start().<br />http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-javascript-client#cantusegenproxyÁn Bình Trọnghttps://www.blogger.com/profile/03318332653078426382noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-66821397619226800582014-01-24T10:50:51.782-08:002014-01-24T10:50:51.782-08:00Just a question and a comment. Did you use $emit i...Just a question and a comment. Did you use $emit instead of $broadcast so that the event would only be published on $rootScope? <br /><br />Also, wouldn't it be a little cleaner to use $rootScope.$on instead of scope.$parent.$on?<br /><br />Thanks for the post!Anonymoushttps://www.blogger.com/profile/01033057109507813294noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-37442516796376348952013-12-09T02:21:58.886-08:002013-12-09T02:21:58.886-08:00How about creating an open source project where we...How about creating an open source project where we can include all of these approaches? Anyone with a new idea can send a pull request and contribute code to it.Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-32166166250511420582013-12-05T22:05:57.819-08:002013-12-05T22:05:57.819-08:00Austin,
You can find the server code in the follo...Austin,<br /><br />You can find the server code in the following post: http://sravi-kiran.blogspot.com/2013/05/HookingUpAspNetSignalRWithAngularJS.html<br /><br />You can find a more advanced sample in this github repo: https://github.com/sravikiran/SignalRAngularJSStockTicker<br /><br />If you still need any specific help, shoot me a mail using the contact me link at the top. I will be happy to help :)Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-71591772072985570622013-12-05T07:12:28.685-08:002013-12-05T07:12:28.685-08:00Could you post the server code or whole project?Could you post the server code or whole project?Anonymoushttps://www.blogger.com/profile/16029143707634254530noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-17462828583416905272013-12-02T03:14:48.098-08:002013-12-02T03:14:48.098-08:00As an addition to that: with this approach there i...As an addition to that: with this approach there is a possibility of collision with names. In example name 'aceptGreet' can already emitted in some other module for different purpose.<br /><br />To solve that how about adding 2 additional methods in service:<br />var prefix = "myGreatPrefix."<br />var $emit = function (name, args) {<br /> $rootScope.$apply(function () {<br /> $rootScope.$emit(prefix + name, args);<br /> });<br /> };<br /><br /> var $on = function (name, listener) {<br /> $rootScope.$on(prefix + name, listener);<br /> };<br /><br /><br /><br />In that case you would use call to service<br /><br />sigalRSvc.$on("greeting", function (e, message) {<br /> console.debug(message); <br /> });Anonymoushttps://www.blogger.com/profile/07222416235865560607noreply@blogger.comtag:blogger.com,1999:blog-1007651349729494127.post-83503891636283222852013-11-12T12:15:35.355-08:002013-11-12T12:15:35.355-08:00Thanks Juan. This approach makes the things cleane...Thanks Juan. This approach makes the things cleaner!Rabi Kiranhttps://www.blogger.com/profile/14704377348226567479noreply@blogger.com