@not3/sdk
    Preparing search index...

    Class P2PReceiver

    Receives a single file from a P2PSender over a WebRTC data channel.

    Every frame is decrypted and sequence-checked as it arrives, so validation finishes the instant the last chunk lands. Failed chunks are re-requested (nack) and the sender rewinds, which keeps writes strictly sequential — a requirement for streaming sinks. Memory stays bounded: a chunk is written through setBytes before the next one is processed.

    On any unrecoverable failure the partial data already handed to setBytes stays intact; resume by constructing a fresh receiver and passing the validated byte count as resumeOffset.

    Index

    Constructors

    Methods

    • Cancel the transfer, telling the peer about it.

      Returns Promise<void>

      A promise resolving once the abort was attempted.

    • The file metadata announced by the sender.

      Returns Promise<P2PMeta>

      A promise resolving once the meta message decrypted, and rejecting if the transfer fails before that.

    • Join the session and receive the file.

      Parameters

      • setBytes: SetBytesFn

        The sink for validated, decrypted chunks. Called strictly in order; the returned promise is awaited before the next chunk is read.

      • resumeOffset: number = 0

        How many bytes the sink already holds. Rounded down to the previous chunk boundary.

      Returns Promise<void>

      A promise resolving once the sender confirmed the transfer.