Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
Merge pull request #110 from reTHINK-project/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
luistduarte authored Nov 29, 2018
2 parents db7d994 + bf44b4c commit 68f0389
Show file tree
Hide file tree
Showing 16 changed files with 361 additions and 194 deletions.
21 changes: 9 additions & 12 deletions examples/learning/learningPlayerDemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,26 @@ let elearningPlayer;

function hypertyLoaded(result) {

console.log('LearningPlayer hyperty loaded!! ', result);
console.log('ElearningPlayer hyperty loaded!! ', result);

elearningPlayer = result.instance;

elearningPlayer.retrieveQuizzes('data://sharing-cities-dsm/elearning').then((result) => {

console.info('[LearningPlayerDemo] quizzes: ', result);
console.info('[ElearningPlayerDemo] quizzes: ', result);

elearningPlayer.initQuizSubmission().then(()=>{
elearningPlayer.invite('hyperty://sharing-cities-dsm/elearning').then(() => {
console.log('[ElearningPlayerDemo] invited "hyperty://sharing-cities-dsm/elearning"');
});

}).catch((reason) => {
console.info('[LearningPlayerDemo] start failed | ', reason);
});

elearningPlayer._resumeReporters().then((result) => {

elearningPlayer.initQuizSubmission();



})


}).catch((reason) => {
console.info('[LearningPlayerDemo] start failed | ', reason);
});

}


19 changes: 10 additions & 9 deletions examples/simple-chat/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ function addParticipantEvent(event) {
let participantEl = '<div class="row">' +
'<div class="input-field col s8">' +
' <input class="input-email" name="email" id="email-' + countParticipants + '" required aria-required="true" type="text" >' +
' <label for="email-' + countParticipants + '">Participant Email</label>' +
' <label for="email-' + countParticipants + '">Hyperty URL</label>' +
'</div>' +
'<div class="input-field col s4">' +
/* '<div class="input-field col s4">' +
' <input class="input-domain" name="domain" id="domain-' + countParticipants + '" type="text"">' +
' <label for="domain-' + countParticipants + '">Participant domain</label>' +
'</div>' +
'</div>' +*/
'</div>';

participants.append(participantEl);
Expand Down Expand Up @@ -263,7 +263,9 @@ function createRoomEvent(event) {
getSectionTpl().then(() => {
console.log('[SimpleChatDemo - Create Room] - Section Template ready:', name, participants);
const CRMaddressTickets = 'hyperty://sharing-cities-dsm/crm/tickets';
return simpleChat.create(name, [{ user: CRMaddressTickets }]);
// return simpleChat.create(name, [{ user: CRMaddressTickets }]);
return simpleChat.create(name, users);
//return simpleChat.create(name, participants);
}).then((chatController) => {

let isOwner = true;
Expand Down Expand Up @@ -372,9 +374,9 @@ function prepareChat(chatController, isOwner, toReload = null) {
console.log('[SimpleChatDemo ] onUserAdded Event:', event);
const participantHypertyURL = event.hypertyURL;
if (chatController._dataObjectReporter) {
debugger;
const objectUrl = chatController._dataObjectReporter._url;
simpleChat.newParticipant('hyperty://sharing-cities-dsm/crm', participantHypertyURL, objectUrl);
// debugger;
// const objectUrl = chatController._dataObjectReporter._url;
// simpleChat.newParticipant('hyperty://sharing-cities-dsm/crm', participantHypertyURL, objectUrl);

}
processNewUser(event);
Expand Down Expand Up @@ -861,9 +863,8 @@ function closeChat(chatController) {
console.log('Chat closed: ', result);
const participantHypertyURL = event.hypertyURL;
if (chatController._dataObjectReporter) {
debugger;
const objectUrl = chatController._dataObjectReporter._url;
simpleChat.closeTicket('hyperty://sharing-cities-dsm/crm', participantHypertyURL, objectUrl);
// simpleChat.closeTicket('hyperty://sharing-cities-dsm/crm', participantHypertyURL, objectUrl);
}

let createRoomModal = $('.create-chat');
Expand Down
2 changes: 1 addition & 1 deletion examples/user-activity/UserActivityObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function hypertyLoaded(result, runtimeLoader = null) {

runtimeLoader.authorise('google.com', 'user_activity_context').then(function(value) {
}).catch(function(err) {
log.log(err);
console.log(err);

});

Expand Down
1 change: 1 addition & 0 deletions examples/wallet/Wallet.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<p>- Tokens: <a class="token-value">-</a></p>
<p>- Ranking: <a class="wallet-ranking">-</a></p>
<p>- Bonus credit: <a class="bonus-credit">-</a></p>
<p>- # Accounts: <a class="accounts">-</a></p>

<button class="wallet-delete">Delete</button>

Expand Down
6 changes: 4 additions & 2 deletions examples/wallet/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,19 @@ function hypertyReady(result, identity) {
console.log('Wallet new update', event);
if (event.field == 'balance') {
$('.token-value').text(event.data);

}
else if (event.field == 'ranking') {
$('.wallet-ranking').text(event.data);
}
else if (event.field == 'accounts') {
$('.accounts').text(event.data.length);
}
else if (event.field == 'bonus-credit') {
$('.bonus-credit').text(event.data);
}
}

const profileInfo = { ageRange: '18-25', workplace: 'Lisbon', cause: '0', balance: 10 };
const profileInfo = { ageRange: '18-25', workplace: 'Lisbon', cause: 'user-guid://school-0', balance: 10 };
identity.profile = profileInfo;
result.instance.start(afterUpdate, identity);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dev-hyperty",
"version": "0.6.0",
"version": "0.7.0",
"description": "Source code of hyperties",
"main": ".eslintrc.js",
"directories": {
Expand Down
14 changes: 12 additions & 2 deletions src/connector/Connector.hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ class Connector {

console.info('---------------- Syncher Subscribe (Auto Subscribe) ---------------- \n');
console.info('Subscribe URL Object ', event);
syncher.subscribe(_this._objectDescURL, event.url).then(function(dataObjectObserver) {
let input = {
schema: _this._objectDescURL,
resource: event.url
};

syncher.subscribe(input).then(function(dataObjectObserver) {
console.info('1. Return Subscribe Data Object Observer', dataObjectObserver);
_this._controllers[event.from].dataObjectObserver = dataObjectObserver;
}).catch(function(reason) {
Expand All @@ -159,7 +164,12 @@ class Connector {

console.info('---------------- Syncher Subscribe (Auto Accept) ---------------- \n');
console.info('Subscribe URL Object ', event);
syncher.subscribe(_this._objectDescURL, event.url ).then(function(dataObjectObserver) {
let input = {
schema: _this._objectDescURL,
resource: event.url
};

syncher.subscribe(input).then(function(dataObjectObserver) {
console.info('1. Return Subscribe Data Object Observer', dataObjectObserver);

let connectionController = new ConnectionController(syncher, _this._domain, _this._configuration, _this._removeController, _this, event.from);
Expand Down
7 changes: 6 additions & 1 deletion src/dtwebrtc/DTWebRTC.hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ class DTWebRTC extends EventEmitter { // extends EventEmitter because we need to

setTimeout( () => {
// Subscribe to Object
this._syncher.subscribe(this._objectDescURL, event.url).then((objObserver) => {
let input = {
schema: this._objectDescURL,
resource: event.url
};

this._syncher.subscribe(input).then((objObserver) => {
console.info("[DTWebRTC]: [_onNotification] objObserver ", objObserver);
// if successful, we get an observer object back
this.objObserver = objObserver
Expand Down
4 changes: 1 addition & 3 deletions src/group-chat-manager/GroupChatManager.hy.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{
"language": "javascript",
"signature": "",
"configuration": {
"backup": true,
"heartBeat": 60
"configuration": {
},
"hypertyType": [
"chat"
Expand Down
8 changes: 7 additions & 1 deletion src/hello-world/HelloWorldObserver.hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ class HelloWorldObserver extends EventEmitter {
// Acknowledge reporter about the Invitation was received
event.ack();

let input = {
schema: _this._objectDescURL,
resource: event.url,
store: true,
p2p: false
};
// Subscribe Hello World Object
_this._syncher.subscribe(_this._objectDescURL, event.url, true, false).then(function(helloObjtObserver) {
_this._syncher.subscribe(input).then(function(helloObjtObserver) {

// Hello World Object was subscribed
console.info(helloObjtObserver);
Expand Down
2 changes: 2 additions & 0 deletions src/hello-world/HelloWorldReporter.hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class HelloWorldReporter {
let input = Object.assign({resources: ['hello']}, {});
input.backup = _this._backup;
input.reuseURL = true;
input.mutual = false;
input.domain_registration = false;

syncher.create(_this._objectDescURL, [hypertyURL], hello, true, false, 'hello', {}, input).then(function(helloObjtReporter) {
console.info('1. Return Created Hello World Data Object Reporter', helloObjtReporter);
Expand Down
33 changes: 27 additions & 6 deletions src/learning/ElearningPlayer.hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ElearningPlayer {

return new Promise((resolve) => {

function keepTrying() {
/* function keepTrying() {
_this.reporter.invitations = [];
_this.reporter.inviteObservers([observer]);
Expand All @@ -100,20 +100,40 @@ class ElearningPlayer {
keepTrying();
}, 100);
});
}*/

if (_this.reporter) {
console.log('[ElearningPlayer.invite] reporter ', _this.reporter)
_this.reporter.inviteObservers([observer])
console.info('[ElearningPlayer] invited: ', observer);

resolve();

} else {
reject('[ElearningPlayer.invite] Reporter not created yet');
}
keepTrying();
});

}


initQuizSubmission() {
let _this = this;

return new Promise((resolve) => {

_this._resumeReporters().then((result) => {

let _this = this;
if (_this.reporter == null) {
_this.syncher.create(_this.objectDescURL, [], {}, true, false, 'elearning', {}, { resources: ['learning-context'], "domain_registration": false })
console.log('[ElearningPlayer] resume ', result);

if (!result) {
let input = {
resources: ['learning-context'],
"domain_registration": false,
"domain_routing": false
};

_this.syncher.create(_this.objectDescURL, [], {}, true, false, 'elearning', {}, input)
.then((reporter) => {
_this.reporter = reporter;
console.log('[ElearningPlayer] DataObjectReporter', _this.reporter);
Expand All @@ -127,7 +147,8 @@ class ElearningPlayer {
resolve(true);
}
});
}
});
}


answer(id, answers) {
Expand Down
16 changes: 14 additions & 2 deletions src/location/LocationReporter.hy.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ class LocationHypertyFactory {
startPositionBroadcast() {
let _this = this;
if (_this.reporter == null) {
_this.syncher.create(_this.objectDescURL, [], position(), true, false, 'location', {}, { resources: ['location-context'], "domain_registration": false })
let input = {
resources: ['location-context'],
"domain_registration": false,
"domain_routing": false
};

_this.syncher.create(_this.objectDescURL, [], position(), true, false, 'location', {}, input)
.then((reporter) => {
_this.reporter = reporter;
console.log('[LocationReporter] DataObjectReporter', _this.reporter);
Expand All @@ -167,7 +173,13 @@ class LocationHypertyFactory {

let _this = this;
if (_this.reporter == null) {
_this.syncher.create(_this.objectDescURL, [], position(), true, false, 'location', {}, { resources: ['location-context'], "domain_registration": false })
let input = {
resources: ['location-context'],
"domain_registration": false,
"domain_routing": false
};

_this.syncher.create(_this.objectDescURL, [], position(), true, false, 'location', {}, input)
.then((reporter) => {
_this.reporter = reporter;
console.log('[LocationReporter] DataObjectReporter', _this.reporter);
Expand Down
Loading

0 comments on commit 68f0389

Please sign in to comment.