Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
websocket url
Browse files Browse the repository at this point in the history
  • Loading branch information
shirishgoyal committed Jan 28, 2016
1 parent 07980ca commit beeb0ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions static/js/crowdsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions static/js/task-feed/controllers/task-feed.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
.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');
return;
}

var ws = $websocket.$new({
url: 'ws://localhost:8000/ws/foo?subscribe-broadcast',
url: $rootScope.getWebsocketUrl() + '/ws/foo?subscribe-broadcast',
lazy: true,
reconnect: true
});
Expand Down

0 comments on commit beeb0ee

Please sign in to comment.