private static void ProcessMessage(object rawMessage, object tag) { if (rawMessage is FunctionRequestMessage) { FunctionRequestMessage functionRequestMessage = rawMessage as FunctionRequestMessage; Base.ClientControlManager.MF.Handle(new Packet(functionRequestMessage.Packet), functionRequestMessage.ClientID); return; } int id = (int)tag; Packet packet = default(Packet); if (rawMessage is ChildProcessLogListRequestMessage) { ChildProcessLogListRequestMessage childProcessLogListRequestMessage = rawMessage as ChildProcessLogListRequestMessage; RCProcess rcprocess = Base.Client[childProcessLogListRequestMessage.ProcessName]; ChildProcessLogListReplyMessage value = new ChildProcessLogListReplyMessage(childProcessLogListRequestMessage.ClientID, rcprocess.Name, rcprocess.ChildProcesses); packet = SerializeWriter.ToBinary <ChildProcessLogListReplyMessage>(value); } else if (rawMessage is ChildProcessLogRequestMessage) { ChildProcessLogRequestMessage childProcessLogRequestMessage = rawMessage as ChildProcessLogRequestMessage; RCProcess rcprocess2 = Base.Client[childProcessLogRequestMessage.ProcessName]; List <RCProcess.ChildProcessLog> log = null; RCProcess.ChildProcessLogs childLog = rcprocess2.GetChildLog(childProcessLogRequestMessage.ProcessID); if (childLog != null) { log = childLog.LogLiness; } ChildProcessLogReplyMessage value2 = new ChildProcessLogReplyMessage(childProcessLogRequestMessage.ClientID, childProcessLogRequestMessage.ProcessName, childProcessLogRequestMessage.ProcessID, log); packet = SerializeWriter.ToBinary <ChildProcessLogReplyMessage>(value2); } else if (rawMessage is ChildProcessLogConnectMessage) { ChildProcessLogConnectMessage childProcessLogConnectMessage = rawMessage as ChildProcessLogConnectMessage; RCProcess rcprocess3 = Base.Client[childProcessLogConnectMessage.ProcessName]; RCProcess.ChildProcessLogs childLog2 = rcprocess3.GetChildLog(childProcessLogConnectMessage.ProcessID); if (childLog2 != null && childLog2.CanConnect) { childLog2.OnLog += Base.ClientControlManager.ClientProcessChildProcessLog; } } else if (rawMessage is ChildProcessLogDisconnectMessage) { ChildProcessLogDisconnectMessage childProcessLogDisconnectMessage = rawMessage as ChildProcessLogDisconnectMessage; RCProcess rcprocess4 = Base.Client[childProcessLogDisconnectMessage.ProcessName]; RCProcess.ChildProcessLogs childLog3 = rcprocess4.GetChildLog(childProcessLogDisconnectMessage.ProcessID); if (childLog3 != null) { childLog3.OnLog -= Base.ClientControlManager.ClientProcessChildProcessLog; } } else if (rawMessage is ExeInfoRequestMessage) { ExeInfoRequestMessage exeInfoRequestMessage = rawMessage as ExeInfoRequestMessage; RCProcess rcprocess5 = Base.Client[exeInfoRequestMessage.ProcessName]; ExeInfoReplyMessage exeInfoReplyMessage = new ExeInfoReplyMessage(exeInfoRequestMessage.ClientID, rcprocess5.Name); try { DirectoryInfo directoryInfo = new DirectoryInfo(Path.Combine(BaseConfiguration.WorkingDirectory, rcprocess5.WorkingDirectory)); List <FileInfo> list = new List <FileInfo>(); list.AddRange(directoryInfo.GetFiles("*.dll", SearchOption.AllDirectories)); list.AddRange(directoryInfo.GetFiles("*.exe", SearchOption.AllDirectories)); foreach (FileInfo fileInfo in list) { exeInfoReplyMessage.AddFile(fileInfo.FullName.Substring(directoryInfo.FullName.Length + 1), fileInfo.LastWriteTime); } } finally { packet = SerializeWriter.ToBinary <ExeInfoReplyMessage>(exeInfoReplyMessage); } } if (packet.Bytes.Array != null) { FunctionReplyMessage message = new FunctionReplyMessage(packet.Bytes, id); Base.ClientControlManager.Send <FunctionReplyMessage>(message); } }
private void SendFunctionProtocol(User user, ArraySegment <byte> data, int clientID) { FunctionRequestMessage value = new FunctionRequestMessage(data, user.ClientId); Base.ClientServer.SendMessage(clientID, SerializeWriter.ToBinary <FunctionRequestMessage>(value)); }