From afdca8364071bea3e7f27da6beb60d727d8d026c Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Mon, 17 Nov 2025 22:31:58 +0100 Subject: [PATCH] Add createDataChannel method to RondevuPeer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a public method to create RTCDataChannels for sending/receiving arbitrary data between peers. The offerer can call this method before creating an offer, and the answerer will receive the channel via the existing 'datachannel' event. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/peer/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/peer/index.ts b/src/peer/index.ts index d5d40e3..cac1141 100644 --- a/src/peer/index.ts +++ b/src/peer/index.ts @@ -179,6 +179,15 @@ export default class RondevuPeer extends EventEmitter { return this.pc.addTrack(track, ...streams); } + /** + * Create a data channel for sending and receiving arbitrary data + * This should typically be called by the offerer before creating the offer + * The answerer will receive the channel via the 'datachannel' event + */ + createDataChannel(label: string, options?: RTCDataChannelInit): RTCDataChannel { + return this.pc.createDataChannel(label, options); + } + /** * Close the connection and clean up */