Show More
@@ -1,62 +1,62 b'' | |||
|
1 | 1 | // # Copyright (C) 2010-2016 RhodeCode GmbH |
|
2 | 2 | // # |
|
3 | 3 | // # This program is free software: you can redistribute it and/or modify |
|
4 | 4 | // # it under the terms of the GNU Affero General Public License, version 3 |
|
5 | 5 | // # (only), as published by the Free Software Foundation. |
|
6 | 6 | // # |
|
7 | 7 | // # This program is distributed in the hope that it will be useful, |
|
8 | 8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 | 9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 | 10 | // # GNU General Public License for more details. |
|
11 | 11 | // # |
|
12 | 12 | // # You should have received a copy of the GNU Affero General Public License |
|
13 | 13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
14 | 14 | // # |
|
15 | 15 | // # This program is dual-licensed. If you wish to learn more about the |
|
16 | 16 | // # AppEnlight Enterprise Edition, including its added features, Support |
|
17 | 17 | // # services, and proprietary license terms, please see |
|
18 | 18 | // # https://rhodecode.com/licenses/ |
|
19 | 19 | |
|
20 | 20 | angular.module('appenlight.components.channelstream', []) |
|
21 | 21 | .component('channelstream', { |
|
22 | 22 | controller: ChannelstreamController, |
|
23 | 23 | bindings: { |
|
24 | 24 | config: '=' |
|
25 | 25 | } |
|
26 | 26 | }); |
|
27 | 27 | |
|
28 | 28 | ChannelstreamController.$inject = ['$rootScope', 'stateHolder', 'userSelfPropertyResource']; |
|
29 | 29 | |
|
30 | 30 | function ChannelstreamController($rootScope, stateHolder, userSelfPropertyResource){ |
|
31 | 31 | if (stateHolder.AeUser.id === null){ |
|
32 | 32 | return |
|
33 | 33 | } |
|
34 | 34 | userSelfPropertyResource.get({key: 'websocket'}, function (data) { |
|
35 | 35 | stateHolder.websocket = new ReconnectingWebSocket(this.config.ws_url + '/ws?conn_id=' + data.conn_id); |
|
36 | 36 | stateHolder.websocket.onopen = function (event) { |
|
37 | 37 | console.log('open'); |
|
38 | 38 | }; |
|
39 | 39 | stateHolder.websocket.onmessage = function (event) { |
|
40 | 40 | var data = JSON.parse(event.data); |
|
41 |
$ |
|
|
41 | $rootScope.$apply(function (scope) { | |
|
42 | 42 | _.each(data, function (message) { |
|
43 | 43 | console.log('channelstream-message', message); |
|
44 | 44 | if(typeof message.message.topic !== 'undefined'){ |
|
45 | 45 | $rootScope.$broadcast( |
|
46 | 46 | 'channelstream-message.'+message.message.topic, message); |
|
47 | 47 | } |
|
48 | 48 | else{ |
|
49 | 49 | $rootScope.$broadcast('channelstream-message', message); |
|
50 | 50 | } |
|
51 | 51 | }); |
|
52 | 52 | }); |
|
53 | 53 | }; |
|
54 | 54 | stateHolder.websocket.onclose = function (event) { |
|
55 | 55 | console.log('closed'); |
|
56 | 56 | }; |
|
57 | 57 | |
|
58 | 58 | stateHolder.websocket.onerror = function (event) { |
|
59 | 59 | console.log('error'); |
|
60 | 60 | }; |
|
61 | 61 | }.bind(this)); |
|
62 | 62 | } |
General Comments 0
You need to be logged in to leave comments.
Login now