@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.
Files changed (2) hide show
  1. package/core/node.mjs +9 -0
  2. 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() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hive-p2p/server",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },