@hive-p2p/server 1.0.48 → 1.0.49
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/core/node.mjs +9 -0
- package/package.json +1 -1
package/core/node.mjs
CHANGED
|
@@ -145,7 +145,16 @@ export class Node {
|
|
|
145
145
|
get publicUrl() { return this.services?.publicUrl; }
|
|
146
146
|
get time() { return CLOCK.time; }
|
|
147
147
|
|
|
148
|
+
/** Triggered when a new peer connection is established.
|
|
149
|
+
* @param {function} callback can use arguments: (peerId:string, direction:string) */
|
|
150
|
+
onPeerConnect(callback) { this.peerStore.on('connect', callback); }
|
|
151
|
+
|
|
152
|
+
/** Triggered when a new message is received.
|
|
153
|
+
* @param {function} callback can use arguments: (senderId:string, data:any) */
|
|
148
154
|
onMessageData(callback) { this.messager.on('message', callback); }
|
|
155
|
+
|
|
156
|
+
/** Triggered when a new gossip message is received.
|
|
157
|
+
* @param {function} callback can use arguments: (senderId:string, topic:string, data:any) */
|
|
149
158
|
onGossipData(callback) { this.gossip.on('gossip', callback); }
|
|
150
159
|
|
|
151
160
|
async start() {
|