-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathload.js
More file actions
44 lines (35 loc) · 932 Bytes
/
load.js
File metadata and controls
44 lines (35 loc) · 932 Bytes
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
'use strict';
// Connect to the Socket Instance
const etherpad = require('./index.js');
const async = require('async');
const host = 'http://127.0.0.1:9001/p/test';
// For now let's create 5 lurking clients and 1 author.
const c = ['a', 'a', 'a', 'a', 'l', 'a'];
const newAuthor = () => {
const pad = etherpad.connect(host);
pad.on('connected', (padState) => {
console.log('Connected Author to', padState.host);
setInterval(() => {
pad.append('Test'); // Appends Hello to the Pad contents
}, 200);
});
};
const newLurker = () => {
const pad = etherpad.connect(host);
pad.on('connected', (padState) => {
console.log('Connected new lurker to', padState.host);
});
};
async.eachSeries(c, (type, callback) => {
setTimeout(() => {
if (type === 'l') {
newLurker();
callback();
}
if (type === 'a') {
newAuthor();
callback();
}
}, 1);
}, (err) => {
});