holepunch-hop 0.3.5 → 0.3.6
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/package.json +1 -1
- package/src/index.js +19 -6
- package/src/peers.js +5 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -249,13 +249,26 @@ class HolepunchWorker extends EventEmitter {
|
|
|
249
249
|
// from peer generating the invite
|
|
250
250
|
this.Peers.setRole({ pubkey: message.data.publickey, codename: message.data.codename, name: message.data.name })
|
|
251
251
|
} else if (message.task === 'cue-space') {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
// first time or turning
|
|
253
|
+
if (Object.keys(reEstablishShort.peer).length === 0) {
|
|
254
|
+
this.Peers.peerAlreadyJoinSetData(message.data)
|
|
255
|
+
let peerActionData = this.Peers.peerHolder[message.data.publickey]
|
|
256
|
+
this.Peers.routeDataPath(message.data.publickey, peerActionData.data)
|
|
257
|
+
} else {
|
|
258
|
+
this.Peers.peerAlreadyJoinSetData(message.data)
|
|
259
|
+
let peerActionData = this.Peers.peerHolder[message.data.publickey]
|
|
260
|
+
this.Peers.routeDataPath(reEstablishShort.peer.value.livePeerkey, peerActionData.data)
|
|
261
|
+
}
|
|
255
262
|
} else if (message.task === 'public-n1-experiment') {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
263
|
+
if (Object.keys(reEstablishShort.peer).length === 0) {
|
|
264
|
+
this.Peers.peerAlreadyJoinSetData(message.data)
|
|
265
|
+
let peerActionData = this.Peers.peerHolder[message.data.publickey]
|
|
266
|
+
this.Peers.routeDataPath(message.data.publickey, peerActionData.data)
|
|
267
|
+
} else {
|
|
268
|
+
this.Peers.peerAlreadyJoinSetData(message.data)
|
|
269
|
+
let peerActionData = this.Peers.peerHolder[message.data.publickey]
|
|
270
|
+
this.Peers.routeDataPath(reEstablishShort.peer.value.livePeerkey, peerActionData.data)
|
|
271
|
+
}
|
|
259
272
|
}
|
|
260
273
|
}
|
|
261
274
|
}
|
package/src/peers.js
CHANGED
|
@@ -78,7 +78,9 @@ class NetworkPeers extends EventEmitter {
|
|
|
78
78
|
*
|
|
79
79
|
*/
|
|
80
80
|
setupConnectionBegin = function (peerNetwork) {
|
|
81
|
-
|
|
81
|
+
this.peerNetwork = peerNetwork
|
|
82
|
+
for (let sPeer of this.peerNetwork) {
|
|
83
|
+
// sPeer.value.key = publicKeylive
|
|
82
84
|
if (sPeer.value.settopic === true) {
|
|
83
85
|
// client role
|
|
84
86
|
this.topicConnect(sPeer.value.topic)
|
|
@@ -107,8 +109,6 @@ class NetworkPeers extends EventEmitter {
|
|
|
107
109
|
*/
|
|
108
110
|
listenNetwork = function () {
|
|
109
111
|
this.swarm.on('connection', (conn, info) => {
|
|
110
|
-
// console.log('peerinfo FIRST------------')
|
|
111
|
-
// console.log(info)
|
|
112
112
|
// save peer connection instance for ongoing communication
|
|
113
113
|
// listen for replication NEED UPTATED LOGIC
|
|
114
114
|
this.store.replicate(conn)
|
|
@@ -176,10 +176,11 @@ class NetworkPeers extends EventEmitter {
|
|
|
176
176
|
|
|
177
177
|
if (serverStatus === true) {
|
|
178
178
|
// set to live
|
|
179
|
+
// update livePeerkey to true??
|
|
179
180
|
let originalKey = ''
|
|
180
181
|
for (let savePeer of this.peerNetwork) {
|
|
181
182
|
if (savePeer.value.topic === topicServer.topic) {
|
|
182
|
-
originalKey = savePeer.value.publickey
|
|
183
|
+
originalKey = savePeer.value.publickey
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
186
|
// need original connection public key
|