hsync 0.20.0 → 0.21.0
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/cli.js +0 -3
- package/connection.js +6 -0
- package/dist/hsync.js +2 -2
- package/dist/hsync.min.js +1 -1
- package/lib/peers.js +3 -6
- package/package.json +1 -1
package/lib/peers.js
CHANGED
|
@@ -12,10 +12,6 @@ const fetch = require('./fetch');
|
|
|
12
12
|
|
|
13
13
|
function createPacket(topic, payload) {
|
|
14
14
|
let payloadStr = payload;
|
|
15
|
-
console.log('mqttPacket', { topic, payload });
|
|
16
|
-
// if (payload instanceof Uint8Array) {
|
|
17
|
-
// console.log('str payload', new TextDecoder().decode(payload));
|
|
18
|
-
// }
|
|
19
15
|
const packet = mqttPacket.generate({
|
|
20
16
|
qos: 0,
|
|
21
17
|
cmd: 'publish',
|
|
@@ -50,6 +46,7 @@ function initPeers(hsyncClient) {
|
|
|
50
46
|
if (!peer) {
|
|
51
47
|
debug('CREATING peer', hostName);
|
|
52
48
|
peer = createRPCPeer({hostName, hsyncClient, timeout});
|
|
49
|
+
peer.myAuth = b64id.generateId();
|
|
53
50
|
if (temporary) {
|
|
54
51
|
peer.rpcTemporary = true;
|
|
55
52
|
}
|
|
@@ -240,14 +237,14 @@ function initPeers(hsyncClient) {
|
|
|
240
237
|
msg = JSON.stringify(msg);
|
|
241
238
|
}
|
|
242
239
|
const topic = `srpc/${hsyncClient.myHostName}`;
|
|
243
|
-
debug('↑ server rpc
|
|
240
|
+
debug('↑ server rpc outbound', msg);
|
|
244
241
|
hsyncClient.mqConn.publish(topic, Buffer.from(msg));
|
|
245
242
|
};
|
|
246
243
|
transport.receiveData = (msg) => {
|
|
247
244
|
if(msg) {
|
|
248
245
|
msg = JSON.parse(msg);
|
|
249
246
|
}
|
|
250
|
-
debug('↓ server rpc
|
|
247
|
+
debug('↓ server rpc inbound', msg);
|
|
251
248
|
transport.emit('rpc', msg);
|
|
252
249
|
};
|
|
253
250
|
const peer = rawr({transport, methods, timeout: 5000});
|