mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 19:03:24 +00:00
Fix datachannel handling: auto-create channels from remote peer
Modified peerDataChannelHandler to automatically create DurableChannel instances when receiving data channels from the remote peer. This fixes the connection flow where the answerer needs to receive the data channel that the offerer created. Previously, the handler only attached if a DurableChannel already existed, which meant incoming channels from the remote peer would be ignored. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -324,11 +324,20 @@ export class DurableConnection extends EventEmitter<DurableConnectionEvents> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.peerDataChannelHandler = (channel: RTCDataChannel) => {
|
this.peerDataChannelHandler = (channel: RTCDataChannel) => {
|
||||||
// Find matching durable channel and attach
|
// Find or create durable channel
|
||||||
const durableChannel = this.channels.get(channel.label);
|
let durableChannel = this.channels.get(channel.label);
|
||||||
if (durableChannel) {
|
|
||||||
durableChannel.attachToChannel(channel);
|
if (!durableChannel) {
|
||||||
|
// Auto-create channel for incoming data channels
|
||||||
|
durableChannel = new DurableChannel(channel.label, {
|
||||||
|
maxQueueSize: this.config.maxQueueSize,
|
||||||
|
maxMessageAge: this.config.maxMessageAge
|
||||||
|
});
|
||||||
|
this.channels.set(channel.label, durableChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attach the received channel
|
||||||
|
durableChannel.attachToChannel(channel);
|
||||||
};
|
};
|
||||||
|
|
||||||
peer.on('connected', this.peerConnectedHandler);
|
peer.on('connected', this.peerConnectedHandler);
|
||||||
|
|||||||
Reference in New Issue
Block a user