The data-channel hub used to open outbound channels and observe inbound ones.
Default tuning and checksum settings applied to every transfer; see FileTransferOptions. Per-send overrides are passed to FileTransferManager.sendFile.
Shuts down the manager: detaches from the hub, cancels every in-flight transfer, and closes all control channels. Idempotent. After closing, FileTransferManager.sendFile throws.
Synchronously invokes every listener registered for event, in registration order.
The event name to emit.
The argument tuple to pass to each listener, matching Events[event].
true if at least one listener was invoked, false if there were none.
The listener list is snapshotted before dispatch, so mutations made by handlers take effect only on subsequent emissions. Listeners are isolated: if one throws, the remaining listeners still run and the error is surfaced via console.error rather than swallowed silently (consistent with LocalMessageBus).
Returns the number of listeners currently registered for event.
The event name to count listeners for.
The count of registered listeners (0 if none).
Removes a previously registered listener for event.
The event name the listener was registered for.
This emitter, for chaining.
Registers a listener that is invoked every time event is emitted.
The event name to listen for.
Callback invoked with the event's argument tuple.
This emitter, for chaining.
Registers a listener that is invoked at most once: it is removed automatically before
being called the first time event is emitted.
The event name to listen for.
Callback invoked with the event's argument tuple on the next emission.
This emitter, for chaining.
Remove a pending one-time listener by passing the same function reference to off.
Removes listeners for a single event, or for all events.
Optionalevent: keyof FileTransferManagerEventsThe event name to clear; if omitted, listeners for every event are removed.
This emitter, for chaining.
Resume an interrupted resumable send by re-announcing it on freshly opened data channels (call after the peer connection reconnects). Only the chunks the receiver is still missing are resent. No-op unless the transfer exists, is a SendTransfer, and was interrupted.
Id of the interrupted send transfer.
Offers a file to a peer and begins the send.
Opens parallelChannels binary data channels to the
peer, wraps input in a FileSource, and returns a started SendTransfer.
Actual byte streaming begins once the receiver accepts the offer.
Identifier of the peer to send to; must have an active connection in the hub.
The file to send: a File, Blob, or custom FileSource.
Optional per-transfer overrides merged over the manager defaults; see SendOptions.
The SendTransfer; subscribe to its events to track progress and completion.
FileTransferError with code InvalidState if the manager is closed, or
ChannelClosed if there is no connection to peerId.
Entry point for peer-to-peer file transfer over WebRTC data channels.
Wraps a DataChannelHub and orchestrates both directions of transfer. For each peer it maintains a single JSON control channel (labelled CONTROL_CHANNEL_LABEL) carrying the offer/accept/complete/cancel handshake, and opens per-transfer binary channels for the framed chunk data. Outbound transfers are started with FileTransferManager.sendFile; inbound offers surface as FileTransferEvent.IncomingOffer events carrying a ReceiveTransfer the application accepts or rejects. The manager routes inbound control messages and data channels to the right Transfer, buffering data channels that arrive before their offer.
Remarks
The manager does not create or negotiate
RTCPeerConnections itself — that is the hub's job. Completed, failed, and cancelled transfers are automatically removed from the manager's registry.Example