-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestConsumer.js
63 lines (56 loc) · 1.83 KB
/
testConsumer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var _ = require('lodash');
var application = 'AwesomeApp';
var neededSkillSets = [
'moreAwesomeSkills',
'awesomeSkills'
];
var redcore = require('./redcore');
var IdHelper = require('./Helpers/IdHelper');
var consumer = redcore.consumer.createConsumer({
id: 'TestConsumer' + IdHelper.GetId(7),
applicationId: application
}, function (error) {
if (!_.isUndefined(error)) {
console.error(error.stack);
}
else {
var i = setInterval(function () {
consumer.needSkillSet(neededSkillSets[0], {
timeout: 5
}, function (error) {
if (error !== null) {
consumer.postJob(neededSkillSets[0], 'awesomeMethod1', {
awesomeness1: true
}, function (error, product, meta) {
if (_.isUndefined(error)) {
console.log("Response to " + meta.needSkillSet + "'s " + meta.skillName
+ " job:");
console.log(product);
console.log(meta);
}
else {
console.error(error.stack);
}
});
}
else {
console.error(error.stack);
}
});
}, 2000);
setTimeout(function () {
clearInterval(i);
consumer.doneWithSkillSet(neededSkillSets[0], function (error) {
if (!_.isUndefined(error)) {
console.error(error);
}
else {
console.log("closing");
consumer.dispose();
}
});
}, 20000);
}
});
consumer.on('ready', function () {
});