private Telnet() : base(Config.Instance.ServerIP, Config.Instance.ServerPort, true) { DataReceived += async(s, e) => { var command = e.Content.Command; Debug.WriteLine("客户端接收到:" + command); switch (command) { //以下为通用 case S_ClientsUpdate: ClientInfo[] clients = e.Content.Data as ClientInfo[]; ClientsUpdate?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case S_LoginFeedback: LoginFeedback feedback = e.Content.Data as LoginFeedback; LoginFeedback?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case S_NoSuchClient: NoSuchClient?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; //以下为控制端 case Screen_NewScreen: ReceivedNewImage?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case WMI_Namespace: WMINamespacesReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case WMI_Classes: WMIClassesReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case WMI_Props: WMIPropsReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case File_RootDirectory: FileSystemRootReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case File_DirectoryContent: FileSystemDirectoryContentReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case File_Download: FileSystemDownloadPartReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case File_ReadDownloadingFileError: FileSystemDownloadErrorReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case File_PrepareUploadingFeedback: FileSystemPrepareForUploadingReceived?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case File_CanSendNextUploadPart: Control.FileUploadHelper.CanSendNextPart.Add((Guid)e.Content.Data); break; case File_WriteUploadingFileError: Control.FileUploadHelper.Error.TryAdd((e.Content.Data as FileFolderFeedback).ID, (e.Content.Data as FileFolderFeedback).Message); break; case File_OperationFeedback: FileSystemFileFolderOperationFeedback?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; //以下为被控端 case Screen_AskForStartScreen: await ScreenHelper.StartSendScreen(); break; case Screen_AskForStopScreen: ScreenHelper.StopSendScreen(); break; case Screen_AskForNextScreen: SendNextScreen?.Invoke(this, new DataReceivedEventArgs(e.Content)); break; case WMI_AskForNamespaces: WMIHelper.SendNamespaces(e.Content); break; case WMI_AskForClasses: WMIHelper.SendWMIClasses(e.Content.Data as string, e.Content); break; case WMI_AskForProps: WMIHelper.SendProperties(e.Content.Data as WMIClassInfo, e.Content); break; case File_AskForRootDirectory: FileSystemHelper.SendDiskDrives(e.Content); break; case File_AskForDirectoryContent: FileSystemHelper.SendDirectoryContent(e.Content); break; case File_AskForDownloading: FileSystemHelper.StartDownloadingToA(e.Content); break; case File_CanSendNextDownloadPart: FileSystemHelper.CanSendNextPart.Add((Guid)e.Content.Data); break; case File_AskForCancelDownload: FileSystemHelper.Cancle.Add((Guid)e.Content.Data); break; case File_AskForStartUpload: FileSystemHelper.StartAcceptingUploading(e.Content); break; case File_Upload: FileSystemHelper.AcceptUploadPartFromA(e.Content); break; case File_AskForCancelUpload: FileSystemHelper.CancelUploadFromA(e.Content); break; case File_Operation: FileSystemHelper.FileFolderOperate(e.Content); break; } }; }