CoreEventMap: {
    onSegmentLoaded: ((params: SegmentLoadDetails) => void);
    onSegmentError: ((params: SegmentErrorDetails) => void);
    onSegmentAbort: ((params: SegmentAbortDetails) => void);
    onSegmentStart: ((params: SegmentStartDetails) => void);
    onPeerConnect: ((params: PeerDetails) => void);
    onPeerClose: ((params: PeerDetails) => void);
    onPeerError: ((params: PeerErrorDetails) => void);
    onChunkDownloaded: ((bytesLength: number, downloadSource: DownloadSource, peerId?: string) => void);
    onChunkUploaded: ((bytesLength: number, peerId: string) => void);
    onTrackerError: ((params: TrackerErrorDetails) => void);
    onTrackerWarning: ((params: TrackerWarningDetails) => void);
}

The CoreEventMap defines a comprehensive suite of event handlers crucial for monitoring and controlling the lifecycle of segment downloading and uploading processes.

Type declaration

  • onSegmentLoaded: ((params: SegmentLoadDetails) => void)

    Invoked when a segment is fully downloaded and available for use.

      • (params): void
      • Parameters

        Returns void

  • onSegmentError: ((params: SegmentErrorDetails) => void)

    Triggered when an error occurs during the download of a segment.

      • (params): void
      • Parameters

        Returns void

  • onSegmentAbort: ((params: SegmentAbortDetails) => void)

    Called if the download of a segment is aborted before completion.

      • (params): void
      • Parameters

        Returns void

  • onSegmentStart: ((params: SegmentStartDetails) => void)

    Fired at the beginning of a segment download process.

      • (params): void
      • Parameters

        Returns void

  • onPeerConnect: ((params: PeerDetails) => void)

    Occurs when a new peer-to-peer connection is established.

      • (params): void
      • Parameters

        • params: PeerDetails

          Contains details about the peer that the event is about.

        Returns void

  • onPeerClose: ((params: PeerDetails) => void)

    Triggered when an existing peer-to-peer connection is closed.

      • (params): void
      • Parameters

        • params: PeerDetails

          Contains details about the peer that the event is about.

        Returns void

  • onPeerError: ((params: PeerErrorDetails) => void)

    Triggered when an error occurs during a peer-to-peer connection.

      • (params): void
      • Parameters

        • params: PeerErrorDetails

          Contains details about the error and the peer that the event is about.

        Returns void

  • onChunkDownloaded: ((bytesLength: number, downloadSource: DownloadSource, peerId?: string) => void)

    Invoked after a chunk of data from a segment has been successfully downloaded.

      • (bytesLength, downloadSource, peerId?): void
      • Parameters

        • bytesLength: number

          The size of the downloaded chunk in bytes.

        • downloadSource: DownloadSource

          The source of the download.

        • OptionalpeerId: string

          The peer ID of the peer that the event is about, if applicable.

        Returns void

  • onChunkUploaded: ((bytesLength: number, peerId: string) => void)

    Called when a chunk of data has been successfully uploaded to a peer.

      • (bytesLength, peerId): void
      • Parameters

        • bytesLength: number

          The length of the segment in bytes.

        • peerId: string

          The peer ID, if the segment was downloaded from a peer

        Returns void

  • onTrackerError: ((params: TrackerErrorDetails) => void)

    Called when an error occurs during the tracker request process.

      • (params): void
      • Parameters

        Returns void

  • onTrackerWarning: ((params: TrackerWarningDetails) => void)

    Called when a warning occurs during the tracker request process.

      • (params): void
      • Parameters

        Returns void