@leofcoin/peernet 0.9.11 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/peernet.js +664 -655
- package/dist/commonjs/peernet.js +664 -655
- package/dist/module/peernet.js +12 -3
- package/package.json +1 -1
- package/src/peer.js +10 -1
- package/src/peernet.js +1 -1
package/dist/module/peernet.js
CHANGED
|
@@ -16,10 +16,17 @@ import MultiWallet from '@leofcoin/multi-wallet';
|
|
|
16
16
|
class PeernetPeer {
|
|
17
17
|
constructor(id, connection) {
|
|
18
18
|
this._events = {};
|
|
19
|
+
this.bw = {
|
|
20
|
+
up: 0,
|
|
21
|
+
down: 0,
|
|
22
|
+
};
|
|
19
23
|
this.id = id;
|
|
20
24
|
this.connection = connection;
|
|
21
25
|
|
|
22
|
-
this.connection.on('data', (message) =>
|
|
26
|
+
this.connection.on('data', (message) => {
|
|
27
|
+
this.bw.down += message.length;
|
|
28
|
+
pubsub.publish('peernet.data', JSON.parse(message.toString()));
|
|
29
|
+
});
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
request(data) {
|
|
@@ -45,6 +52,8 @@ class PeernetPeer {
|
|
|
45
52
|
|
|
46
53
|
write(data) {
|
|
47
54
|
if (!Buffer.isBuffer(data)) data = Buffer.from(data);
|
|
55
|
+
|
|
56
|
+
this.bw.up += data.length;
|
|
48
57
|
this.connection.write(data);
|
|
49
58
|
}
|
|
50
59
|
|
|
@@ -263,7 +272,7 @@ class LeofcoinStorage$1 {
|
|
|
263
272
|
|
|
264
273
|
}
|
|
265
274
|
|
|
266
|
-
var version = "0.
|
|
275
|
+
var version = "0.10.0";
|
|
267
276
|
|
|
268
277
|
var api$1 = {
|
|
269
278
|
version: ({send}) => send({client: '@peernet/api/http', version}),
|
|
@@ -2177,7 +2186,7 @@ class Peernet {
|
|
|
2177
2186
|
*/
|
|
2178
2187
|
this.client = new PeernetClient({...options, id});
|
|
2179
2188
|
if (globalThis.onbeforeunload) {
|
|
2180
|
-
|
|
2189
|
+
globalThis.addEventListener('beforeunload', async () => this.client.close());
|
|
2181
2190
|
}
|
|
2182
2191
|
return this
|
|
2183
2192
|
}
|
package/package.json
CHANGED
package/src/peer.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
export default class PeernetPeer {
|
|
2
2
|
constructor(id, connection) {
|
|
3
3
|
this._events = {}
|
|
4
|
+
this.bw = {
|
|
5
|
+
up: 0,
|
|
6
|
+
down: 0,
|
|
7
|
+
}
|
|
4
8
|
this.id = id
|
|
5
9
|
this.connection = connection
|
|
6
10
|
|
|
7
|
-
this.connection.on('data', (message) =>
|
|
11
|
+
this.connection.on('data', (message) => {
|
|
12
|
+
this.bw.down += message.length
|
|
13
|
+
pubsub.publish('peernet.data', JSON.parse(message.toString()))
|
|
14
|
+
})
|
|
8
15
|
}
|
|
9
16
|
|
|
10
17
|
request(data) {
|
|
@@ -30,6 +37,8 @@ export default class PeernetPeer {
|
|
|
30
37
|
|
|
31
38
|
write(data) {
|
|
32
39
|
if (!Buffer.isBuffer(data)) data = Buffer.from(data)
|
|
40
|
+
|
|
41
|
+
this.bw.up += data.length
|
|
33
42
|
this.connection.write(data)
|
|
34
43
|
}
|
|
35
44
|
|
package/src/peernet.js
CHANGED
|
@@ -249,7 +249,7 @@ export default class Peernet {
|
|
|
249
249
|
*/
|
|
250
250
|
this.client = new Client({...options, id})
|
|
251
251
|
if (globalThis.onbeforeunload) {
|
|
252
|
-
|
|
252
|
+
globalThis.addEventListener('beforeunload', async () => this.client.close());
|
|
253
253
|
}
|
|
254
254
|
return this
|
|
255
255
|
}
|