119 lines
2.7 KiB
TypeScript
119 lines
2.7 KiB
TypeScript
|
|
/**
|
|||
|
|
* 设备信息接口
|
|||
|
|
*/
|
|||
|
|
export interface DeviceInfo {
|
|||
|
|
id: string;
|
|||
|
|
socketId: string;
|
|||
|
|
name: string;
|
|||
|
|
model: string;
|
|||
|
|
osVersion: string;
|
|||
|
|
appVersion: string;
|
|||
|
|
appPackage?: string;
|
|||
|
|
appName?: string;
|
|||
|
|
screenWidth: number;
|
|||
|
|
screenHeight: number;
|
|||
|
|
capabilities: string[];
|
|||
|
|
connectedAt: Date;
|
|||
|
|
lastSeen: Date;
|
|||
|
|
status: 'online' | 'offline' | 'busy';
|
|||
|
|
inputBlocked?: boolean;
|
|||
|
|
isLocked?: boolean;
|
|||
|
|
remark?: string;
|
|||
|
|
publicIP?: string;
|
|||
|
|
systemVersionName?: string;
|
|||
|
|
romType?: string;
|
|||
|
|
romVersion?: string;
|
|||
|
|
osBuildVersion?: string;
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 设备状态接口
|
|||
|
|
*/
|
|||
|
|
export interface DeviceStatus {
|
|||
|
|
cpu: number;
|
|||
|
|
memory: number;
|
|||
|
|
battery: number;
|
|||
|
|
networkSpeed: number;
|
|||
|
|
orientation: 'portrait' | 'landscape';
|
|||
|
|
screenOn: boolean;
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* 设备管理器
|
|||
|
|
*/
|
|||
|
|
declare class DeviceManager {
|
|||
|
|
private devices;
|
|||
|
|
private deviceStatuses;
|
|||
|
|
private socketToDevice;
|
|||
|
|
private logger;
|
|||
|
|
constructor();
|
|||
|
|
/**
|
|||
|
|
* ✅ 清理所有设备记录(服务器重启时调用)
|
|||
|
|
*/
|
|||
|
|
clearAllDevices(): void;
|
|||
|
|
/**
|
|||
|
|
* 添加设备
|
|||
|
|
*/
|
|||
|
|
addDevice(deviceInfo: DeviceInfo): void;
|
|||
|
|
/**
|
|||
|
|
* 移除设备
|
|||
|
|
*/
|
|||
|
|
removeDevice(deviceId: string): boolean;
|
|||
|
|
/**
|
|||
|
|
* 通过Socket ID移除设备
|
|||
|
|
*/
|
|||
|
|
removeDeviceBySocketId(socketId: string): boolean;
|
|||
|
|
/**
|
|||
|
|
* 获取设备信息
|
|||
|
|
*/
|
|||
|
|
getDevice(deviceId: string): DeviceInfo | undefined;
|
|||
|
|
/**
|
|||
|
|
* 通过Socket ID获取设备
|
|||
|
|
*/
|
|||
|
|
getDeviceBySocketId(socketId: string): DeviceInfo | undefined;
|
|||
|
|
/**
|
|||
|
|
* 获取所有设备
|
|||
|
|
*/
|
|||
|
|
getAllDevices(): DeviceInfo[];
|
|||
|
|
/**
|
|||
|
|
* 获取在线设备
|
|||
|
|
*/
|
|||
|
|
getOnlineDevices(): DeviceInfo[];
|
|||
|
|
/**
|
|||
|
|
* 获取设备数量
|
|||
|
|
*/
|
|||
|
|
getDeviceCount(): number;
|
|||
|
|
/**
|
|||
|
|
* 更新设备状态
|
|||
|
|
*/
|
|||
|
|
updateDeviceStatus(socketId: string, status: DeviceStatus): void;
|
|||
|
|
/**
|
|||
|
|
* 获取设备状态
|
|||
|
|
*/
|
|||
|
|
getDeviceStatus(deviceId: string): DeviceStatus | undefined;
|
|||
|
|
/**
|
|||
|
|
* 更新设备连接状态
|
|||
|
|
*/
|
|||
|
|
updateDeviceConnectionStatus(deviceId: string, status: DeviceInfo['status']): void;
|
|||
|
|
/**
|
|||
|
|
* 检查设备是否在线
|
|||
|
|
*/
|
|||
|
|
isDeviceOnline(deviceId: string): boolean;
|
|||
|
|
/**
|
|||
|
|
* 获取设备的Socket ID
|
|||
|
|
*/
|
|||
|
|
getDeviceSocketId(deviceId: string): string | undefined;
|
|||
|
|
/**
|
|||
|
|
* 清理离线设备 (超过指定时间未活跃)
|
|||
|
|
*/
|
|||
|
|
cleanupOfflineDevices(timeoutMs?: number): void;
|
|||
|
|
/**
|
|||
|
|
* 获取设备统计信息
|
|||
|
|
*/
|
|||
|
|
getDeviceStats(): {
|
|||
|
|
total: number;
|
|||
|
|
online: number;
|
|||
|
|
offline: number;
|
|||
|
|
busy: number;
|
|||
|
|
};
|
|||
|
|
}
|
|||
|
|
export default DeviceManager;
|
|||
|
|
//# sourceMappingURL=DeviceManager.d.ts.map
|