import 'webrtc-adapter'; import { AFK, TypedEvent, Cursor, DownloadedFile, FileDownloadProgress } from '../utils'; import type { StateChangeHandler } from '../utils'; import { type FileRequest, DataSwitch, QueryDevices } from './event-adapter'; type ConnectMSG = { action: 'connect'; code: number; message: string; }; type ReadyMSG = { action: 'ready'; data: { nodeName: string; token: string; }; }; export declare class Connection { url: string; iceServers: RTCIceServer[]; iceTransportPolicy: RTCIceTransportPolicy; private minBitrate; private maxBitrate; private startBitrate; private enableAFK; private isMobile; private answerDelayHint; private enableBandwidthDetect; dc: RTCDataChannel; pc: RTCPeerConnection; private candidateCache; event: { connect: TypedEvent; afk: TypedEvent; open: TypedEvent; close: TypedEvent; queue: TypedEvent; ready: TypedEvent; endCandidate: TypedEvent; cursor: TypedEvent; hangUp: TypedEvent; iceStateChange: TypedEvent; disconnect: TypedEvent; receivedLink: TypedEvent; /** * @deprecated: use `receivedStream` instead */ receivedTrack: TypedEvent; receivedStream: TypedEvent; dataChannelConnected: TypedEvent; peerConnectionConnected: TypedEvent; interaction: TypedEvent; /** * @deprecated use `kick` instead */ occupy: TypedEvent; kick: TypedEvent; networkChanged: TypedEvent; echo: TypedEvent; screenshot: TypedEvent; screenshotData: TypedEvent; kickOut: TypedEvent; clientInfo: TypedEvent; clipboard: TypedEvent; encodeSettings: TypedEvent<{ framerate: number; bitrate: number; gopLength: number; }>; deviceInfo: TypedEvent; dataSwitch: TypedEvent; mobileResolutionInfo: TypedEvent<{ width: number; height: number; scale: number; }>; resolutionInfo: TypedEvent<[number, number, number][]>; encodeResolutionSettings: TypedEvent<{ width: number; height: number; }>; receivedFile: TypedEvent; fileTransferApply: TypedEvent; bandwidthDetect: TypedEvent; receivedFileProgress: TypedEvent; }; token: string; afk: AFK; private fileUploadManager?; private fileDownloadManager?; private tan; private ready; private subject; private answerDelayTimer; private mediaStream; constructor(url: string, iceServers: RTCIceServer[], iceTransportPolicy?: RTCIceTransportPolicy, minBitrate?: number, maxBitrate?: number, startBitrate?: number, enableAFK?: boolean, isMobile?: boolean, answerDelayHint?: number, enableBandwidthDetect?: boolean); /** * @description setup signing server socket connect event handler */ private setupSigning; /** * @description setup PeerConnection & listen for iceCandidat/track event */ private setupPeerConnection; private setupFileUploadManager; private setupFileDownloadManager; /** * @description setup DateChannel, listen target video element event and sent by DataChannel */ private setupDataChannel; /** * @description create offer then start to communicate with remote peer */ private linkStart; private hangUp; /** * 3dcat only signing message in screen */ controlAuthority(value: string): Promise; /** * @description change bandwidth with fixed bitrate * @param bitrate kbps */ changeBandwidth(bitrate: number): void; /** * @description change bandwidth with dynamical bitrate(or bitrate range) * @param startBitrate kbps * @param maxBitrate kbps * @param minBitrate kbps */ changeBandwidth(startBitrate: number, maxBitrate: number, minBitrate: number): void; /** * @description stop application manually, terminate node machine and real-time process * dragon only signaling message */ exit(): void; /** * post string data to application directly * @param msg payload * @returns execute result */ emitUIInteraction(msg: string | ArrayBuffer, isTrusted?: boolean): Promise; /** * @description send echo data, node will echo the same data when received EventDelay */ echo(): void; screenshot({ index, left, top, width, height, }?: { index?: number; left?: number; top?: number; width?: number; height?: number; }): void; sendClipboardData(payload: string | Blob): Promise; /** * @description fetch current codec options from node */ echoCodecOptions(): void; /** * @description fetch current mobile screen resolution and scale */ echoMobileResolutionInfo(): void; /** * @description fetch supported resolution of current Windows */ echoResolutionInfo(): void; /** * @description fetch peer node's device info(like monitor count/microphone count etc.) */ echoDevicesInfo(): void; /** * @description change file download seek directory, default is "/Downloads" */ changeSeekDir(dir?: string): Promise; /** * @description checkout file to download, based on the settings directory and file name */ checkoutFile(fileName: string): Promise; /** * @description response file transfer request */ replyFileTransferApply(fileUnique: bigint, allowed: boolean): void; /** * enable File System Access API to download file * @param {number} [threshold=524288000] When the file size is less than the threshold (byte-based, default 500 MB), the original method will be used. */ enableFileSystemAccessAPI(threshold?: number): void; /** * disable File System Access API to download file */ disableFileSystemAccessAPI(): void; /** * @description Set the file upload directory(absolute directory) of the node before sendFile and whether to replace the existing file */ changeUploadDir(dir?: string, replace?: boolean): Promise; sendFile(file: File, onStateChange?: StateChangeHandler): void; /** * @description response file transfer finish */ notifyFileTransferFinish(fileUnique: bigint, result: boolean): void; /** * @description change node machine encode options */ changeCodecOptions({ framerate, bitrate, gopLength, }?: { framerate?: number; bitrate?: number; gopLength?: number; }): void; /** * @description change node machine OS resolution */ changeResolution({ index, width, height, }?: { index?: number; width?: number; height?: number; }): void; switchMonitor(targetScreenIndex: number, currentScreenIndex: number): void; /** * @description change node machine encode resolution */ changeEncodeResolution({ width, height, }?: { width?: number; height?: number; }): void; /** * @description transmits data using the DataChannel, data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView */ send(data: string | Blob | ArrayBuffer | ArrayBufferView, isTrusted?: boolean): void; /** * @description change encoder resolution on the fly * @param scale 0-1 */ changeMobileResolutionScale(scale: number): void; /** * @description change bandwidth by renegotiation * @param bandwidth kbps */ changeBandwidthByRenegotiation(bandwidth?: number): void; /** * @description change bandwidth by renegotiation * @param startBitrate x-google-start-bitrate * @param maxBitrate x-google-max-bitrate * @param minBitrate x-google-min-bitrate */ changeBandwidthByRenegotiation(startBitrate: number, maxBitrate: number, minBitrate: number): void; /** * @description add audio track by renegotiation * @param stream MediaStream */ upgradeAudio(stream: MediaStream, iceRestart?: boolean): Promise; /** * @description add video track by renegotiation * @param stream MediaStream */ upgradeVideo(stream: MediaStream, iceRestart?: boolean): Promise; /** * @description reinitialize node machine webrtc instance */ reset(): void; /** * clean the execution */ destroy(): void; } export {};