fix(guild): live roster gossip and reliable mesh send (v0.1.1)
- GUILD_SYNC consumers receive members[] from platform bundle builder - Dedupe hyperswarm connections per peerId before attaching gossip/attach wires - broadcastGossip: bounded wireReady then always send (matches discovery mesh) Enables live MEMBER_JOIN, MEMBER_ROLE_UPDATE, and PRESENCE_UPDATE without simulateGossip in CI smokes. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -653,6 +653,18 @@ class PearcordGuild extends EventEmitter {
|
|||||||
this.swarm.removeAllListeners('connection')
|
this.swarm.removeAllListeners('connection')
|
||||||
this.swarm.on('connection', (conn) => {
|
this.swarm.on('connection', (conn) => {
|
||||||
const peerId = b4a.toString(conn.remotePublicKey, 'hex')
|
const peerId = b4a.toString(conn.remotePublicKey, 'hex')
|
||||||
|
const prevConn = this.peers.get(peerId)
|
||||||
|
if (prevConn && prevConn !== conn) {
|
||||||
|
try {
|
||||||
|
prevConn.destroy()
|
||||||
|
} catch {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
this._channels.delete(peerId)
|
||||||
|
this._attachChannels.delete(peerId)
|
||||||
|
this._voiceChannels.delete(peerId)
|
||||||
|
this._screenChannels.delete(peerId)
|
||||||
|
}
|
||||||
this.peers.set(peerId, conn)
|
this.peers.set(peerId, conn)
|
||||||
const ch = attachGossipMesh(this, conn)
|
const ch = attachGossipMesh(this, conn)
|
||||||
if (ch) this._channels.set(peerId, ch)
|
if (ch) this._channels.set(peerId, ch)
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ async function broadcastGossip (guild, method, payload) {
|
|||||||
await Promise.all(
|
await Promise.all(
|
||||||
sessions.map(async (session) => {
|
sessions.map(async (session) => {
|
||||||
try {
|
try {
|
||||||
const ok = await wireReady(session, 6000)
|
await wireReady(session, 2000)
|
||||||
if (!ok) return
|
|
||||||
session.send(buf)
|
session.send(buf)
|
||||||
} catch {
|
} catch {
|
||||||
// peer gone
|
// peer gone
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "pearcord-guild",
|
"name": "pearcord-guild",
|
||||||
"version": "0.1.0",
|
"version": "0.1.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"type": "commonjs",
|
"type": "commonjs",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
Reference in New Issue
Block a user