@rongcloud/plugin-wechat-rtc
Version:
@rongcloud/plugin-wechat-rtc
35 lines • 1.1 kB
TypeScript
import { ILogger } from '@rongcloud/engine';
import { RCRTCPingResult } from '../enums/RCRTCPingResult';
import { RTCContext } from '../codec/RTCContext';
/**
* RTCPing 类,在下发的 ping 超时时间 _offlineKickTime 内,未能 Ping 成功则认为 ping 失败
*/
export default class Pinger {
private readonly _context;
private _roomId;
private readonly _logger;
private readonly _gap;
/**
* 记录最近一次成功的 Ping 时间戳
*/
private _latestTimestamp;
constructor(_context: RTCContext, _roomId: string, _logger: ILogger, _gap?: number);
/**
* Ping 失败回调,当失败次数超出 `MAX_FAILED` 时,该方法将被调用
*/
onFailed: (byServer: boolean) => void;
/**
* 单次 ping 结果
*/
onPingResult: undefined | ((result: RCRTCPingResult, dataVersion?: number) => void);
private _started;
private _timer;
/**
* 启动 Ping
*/
start(offlineKickTime: number): void;
private _sendPing;
private _checkAlive;
stop(): void;
}
//# sourceMappingURL=Pinger.d.ts.map