added PeerJS and initial Network service
This commit is contained in:
parent
7e34253495
commit
76eadc17cf
6 changed files with 188 additions and 12 deletions
21
js/controllers/join.js
Normal file
21
js/controllers/join.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('cosign.join').controller('JoinController',
|
||||
function($scope, $rootScope, $routeParams, Network) {
|
||||
|
||||
$scope.connectionId = $routeParams.id;
|
||||
$scope.cosigners = [];
|
||||
|
||||
$scope.init = function() {
|
||||
console.log('-------- init --------');
|
||||
console.log($rootScope.peerId);
|
||||
$scope.cosigners.push($rootScope.peerId);
|
||||
|
||||
Network.connect($scope.connectionId, function(cosigner) {
|
||||
console.log('----- join connect --------');
|
||||
console.log(cosigner);
|
||||
$scope.cosigners.push(cosigner);
|
||||
$scope.$digest();
|
||||
});
|
||||
};
|
||||
});
|
||||
24
js/controllers/signin.js
Normal file
24
js/controllers/signin.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('cosign.signin').controller('SigninController',
|
||||
function($scope, $rootScope, $location, Network) {
|
||||
$rootScope.peerId = null;
|
||||
$scope.peerReady = false;
|
||||
|
||||
// Init peer
|
||||
Network.init(function(pid) {
|
||||
$rootScope.peerId = pid;
|
||||
$rootScope.$digest();
|
||||
|
||||
$scope.peerReady = true;
|
||||
$scope.$digest();
|
||||
});
|
||||
|
||||
$scope.join = function(cid) {
|
||||
console.log('------- join --------');
|
||||
console.log(cid);
|
||||
|
||||
var pid = cid || $rootScope.peerId;
|
||||
$location.path('join/' + pid);
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue