UNPKG

@signiant/media-shuttle-sdk

Version:

The SDK for supporting file transfer to and from Media Shuttle

95 lines 3.93 kB
import PlatformService from '../services/PlatformService'; import { TransferEvent } from '@signiant/media-shuttle-sdk-base'; export interface PlatformTransferEventHandlerOptions { platformService: PlatformService; portalId: string; accountId: string; serviceId: string; userAgent: string; transferUpdateIntervalMillis?: number; } export interface BytesSentInternalData { bytesTransferred?: number; bytesRemaining?: number; etaMillis?: number; rateInBytesPerSecond?: number; } export interface ActiveFileExternalEvent { fileName: string; } export interface FileData { fileId: string; fileName: string; filePath?: string; fileSize?: number; } declare class PlatformTransferEventHandler { private readonly _orderedTransferUpdateManager; private _files; private readonly _completedFileIds; private readonly _portalId; private readonly _serviceId; private readonly _accountId; private readonly _userAgent; private _transferId; private _lastRateInBytesPerSecond; private _numInProgressUpdates; private _transferRateSum; private _lastProtocol; private _activeFileId; private _server; private _relayServer; private _intervalId; private _updateTransferOptionalParams; private readonly _transferUpdateIntervalMillis; private _destinationPath; private _terminalState; private lastError; /** * @param {PlatformTransferEventHandlerOptions} options.platformService {PlatformService} - `platformService` - The `PlatformService` instance * @param {PlatformTransferEventHandlerOptions} options.portalId {string} - The portal used for transfers * @param {PlatformTransferEventHandlerOptions} options.accountId {string} - The accountId used for transfers * @param {PlatformTransferEventHandlerOptions} options.serviceId {string} - The serviceId used for transfers * @param {PlatformTransferEventHandlerOptions} options.transferUpdateIntervalMillis {number} - (Optional) Interval used to update the transfer state */ constructor({ platformService, portalId, userAgent, accountId, serviceId, transferUpdateIntervalMillis, }: PlatformTransferEventHandlerOptions); set files(files: FileData[]); set transferId(transferId: string); enableEventDispatch(): void; disableEventDispatch(): void; handleEvent(event: TransferEvent): Promise<void>; private dispatchRequest; /** * @param updateTransferOptionalParams Update params being evaluated. * @return {PlatformStatus} Evaluates the the updateTransferOptionalParams.status field for terminal state * (COMPLETED, ERROR, CANCELLED), returning if there is a match or undefined if there is not. * @private */ private getTerminalStatus; /** * @param updateTransferOptionalParams {UpdateTransferOptionalParams} The update params. * @param dispatchNow {boolean} In certain cases (like when we start a new file) we need to dispatch updates * immediately so important information is not missed. This flag controls that behaviour. * @private */ private setUpdateTransferOptions; private updateTransfer; /** * The protocol is dispatched once by the app but required at multiple stages of the update so we have little * choice but to cache the value and apply it when it exists :-/ * * @param params The original params * @return cloned version of the params, possibly with a cached protocol property added. */ private withProtocol; private handleStatusChange; private toPlatformProgressStats; private handleBytesSent; private handleProtocol; private handleActiveFile; private getStatusFileIds; set destinationPath(destinationPath: string); get destinationPath(): string; } export default PlatformTransferEventHandler; //# sourceMappingURL=PlatformTransferEventHandler.d.ts.map