From beeb0ee48992bfa7e4987d03c904bc75f48243cd Mon Sep 17 00:00:00 2001 From: Shirish Goyal Date: Thu, 28 Jan 2016 12:45:46 +0530 Subject: [PATCH] websocket url --- static/js/crowdsource.js | 11 +++++++++++ .../js/task-feed/controllers/task-feed.controller.js | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/static/js/crowdsource.js b/static/js/crowdsource.js index 3ef3f639..70b1e8ff 100644 --- a/static/js/crowdsource.js +++ b/static/js/crowdsource.js @@ -67,6 +67,17 @@ function run($http, $rootScope, $window, $location, Authentication) { }); $rootScope.theme = 'default'; + + $rootScope.getWebsocketUrl = function(){ + var host = $location.host(); + var protocol = $location.protocol(); + var port = $location.port(); + + protocol = protocol.replace("http", "ws"); + + return protocol +"://"+ host + ":" + port; + }; + /*$rootScope.$on('oauth:error', function(event, rejection) { if ('invalid_grant' === rejection.data.error) { return; diff --git a/static/js/task-feed/controllers/task-feed.controller.js b/static/js/task-feed/controllers/task-feed.controller.js index 3e18cc28..48556203 100644 --- a/static/js/task-feed/controllers/task-feed.controller.js +++ b/static/js/task-feed/controllers/task-feed.controller.js @@ -11,13 +11,13 @@ .controller('TaskFeedController', TaskFeedController); TaskFeedController.$inject = ['$window', '$location', '$scope', '$mdToast', 'TaskFeed', - '$filter', 'Authentication', 'TaskWorker', 'Project', '$rootScope', '$routeParams', '$websocket', '$timeout']; + '$filter', 'Authentication', 'TaskWorker', 'Project', '$rootScope', '$routeParams', '$websocket']; /** * @namespace TaskFeedController */ function TaskFeedController($window, $location, $scope, $mdToast, TaskFeed, - $filter, Authentication, TaskWorker, Project, $rootScope, $routeParams, $websocket, $timeout) { + $filter, Authentication, TaskWorker, Project, $rootScope, $routeParams, $websocket) { var userAccount = Authentication.getAuthenticatedAccount(); if (!userAccount) { $location.path('/login'); @@ -25,7 +25,7 @@ } var ws = $websocket.$new({ - url: 'ws://localhost:8000/ws/foo?subscribe-broadcast', + url: $rootScope.getWebsocketUrl() + '/ws/foo?subscribe-broadcast', lazy: true, reconnect: true });