@clawchatsai/connector 0.0.61 → 0.0.62
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/dist/webrtc-peer.js +15 -0
- package/package.json +1 -1
package/dist/webrtc-peer.js
CHANGED
|
@@ -70,6 +70,21 @@ export class WebRTCPeerManager extends EventEmitter {
|
|
|
70
70
|
}
|
|
71
71
|
async handleOffer(offer) {
|
|
72
72
|
const { connectionId, sdp, candidates } = offer;
|
|
73
|
+
// ICE restart: existing PC — renegotiate on it, DataChannel stays open.
|
|
74
|
+
const existingPc = this.peerConnections.get(connectionId);
|
|
75
|
+
if (existingPc) {
|
|
76
|
+
console.log(`[WebRTCPeerManager] ICE restart for connection ${connectionId}`);
|
|
77
|
+
await existingPc.setRemoteDescription(new RTCSessionDescription({ sdp, type: 'offer' }));
|
|
78
|
+
for (const rawCandidate of candidates) {
|
|
79
|
+
try {
|
|
80
|
+
await existingPc.addIceCandidate(new RTCIceCandidate(rawCandidate));
|
|
81
|
+
}
|
|
82
|
+
catch { /* ignore */ }
|
|
83
|
+
}
|
|
84
|
+
const answer = await existingPc.createAnswer();
|
|
85
|
+
await existingPc.setLocalDescription(answer);
|
|
86
|
+
return { connectionId, sdp: answer.sdp, candidates: [] };
|
|
87
|
+
}
|
|
73
88
|
console.log(`[WebRTCPeerManager] Handling ICE offer for connection ${connectionId}`);
|
|
74
89
|
const iceServers = this.pendingIceServers.get(connectionId) ?? [
|
|
75
90
|
{ urls: 'stun:stun.l.google.com:19302' },
|