public override void ExecuteCommand(RemoteProcessSession session, StringCommandInfo commandData) { Process[] processes; string firstParam = commandData.GetFirstParam(); if (string.IsNullOrEmpty(firstParam) || firstParam == "*") { processes = Process.GetProcesses(); } else { processes = Process.GetProcesses().Where(p => p.ProcessName.IndexOf(firstParam, StringComparison.OrdinalIgnoreCase) >= 0).ToArray(); } StringBuilder sb = new StringBuilder(); foreach (var p in processes) { sb.AppendLine(string.Format("{0}\t{1}", p.ProcessName, p.Id)); } sb.AppendLine(); session.SendResponse(sb.ToString()); }
public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo) { foreach (var p in commandInfo.Parameters) { session.SendResponse(p); } }
public override void ExecuteCommand(YourSession session, StringCommandInfo commandData) { foreach (var p in commandData.Parameters) { session.SendResponse(p); } }
public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo) { foreach(var p in commandInfo.Parameters) { session.SendResponse(p); } }
public override void ExecuteCommand(TWebSocketSession session, StringCommandInfo commandInfo) { if (string.IsNullOrEmpty(commandInfo.Data)) { ExecuteJsonCommand(session, default(TJsonCommandInfo)); return; } var data = commandInfo.Data; if (data[0] != '{') { int pos = data.IndexOf(' '); session.CurrentToken = data.Substring(0, pos); data = data.Substring(pos + 1); } else { session.CurrentToken = string.Empty; } TJsonCommandInfo jsonCommandInfo; if (!m_IsPrimitiveType) { jsonCommandInfo = JsonConvert.DeserializeObject <TJsonCommandInfo>(data); } else { jsonCommandInfo = (TJsonCommandInfo)Convert.ChangeType(data, m_CommandInfoType); } ExecuteJsonCommand(session, jsonCommandInfo); }
public override void ExecuteCommand(BroadcastSession session, StringCommandInfo commandData) { string message = commandData.Data; session.AppServer.BroadcastMessage(session, message); session.SendResponse("101 message broadcasted"); }
public override void ExecuteCommand(TestSession session, StringCommandInfo commandData) { foreach (var p in commandData.Parameters) { Console.WriteLine("S: " + p); session.SendResponse(p); } }
public override void ExecuteCommand(TestSession session, StringCommandInfo commandData) { // byte[] mark = Encoding.ASCII.GetBytes(string.Format("{0}.{0}", Environment.NewLine)); // MemoryStream ms = new MemoryStream(); // session.SocketSession.ReceiveData(ms, mark); // byte[] data = ms.ToArray(); // session.SocketSession.SendResponse(data); }
public override void ExecuteCommand(TestSession session, StringCommandInfo commandData) { // int length = int.Parse(commandData[0]); // // MemoryStream ms = new MemoryStream(); // session.SocketSession.ReceiveData(ms, length); // byte[] data = ms.ToArray(); // session.SocketSession.SendResponse(data); }
public override void ExecuteCommand(TrieTreeSession session, StringCommandInfo commandInfo) { logger.Info("receive command RMMFetch, argument: " + commandInfo.Data); Stopwatch sw = new Stopwatch(); sw.Start(); var tt = TrieTree.GetInstance(); string[] splits = commandInfo.Data.Split(new char[] { SOH }); int maxlength = 0; string text = splits[0]; int pos = 0; if (splits.Length > 1) { pos = Int32.Parse(splits[1]); } maxlength = text.Length; string temp = null; TrieTreeNode node = null; for (int j = 0; j < maxlength; j++) { temp = text.Substring(j, maxlength - j); node = tt.GetNode(temp, pos); if (node != null) { break; } } sw.Stop(); logger.InfoFormat("timer: {0} ms", sw.ElapsedMilliseconds); string result = null; if (node == null) { result = string.Format("0{0}", SOH); } else { result = string.Format("1{0}{1}{0}{2}{0}{3}{0}", SOH, node.Word, node.Frequency, node.POSValue); } if (node != null) { logger.InfoFormat("return result: {0}, {1}", node.Word, (POSType)node.POSValue); } else { logger.InfoFormat("return result: not found"); } session.SendResponse(result); }
public override void ExecuteCommand(RemoteProcessSession session, StringCommandInfo commandData) { int processId; string processKey = commandData.Parameters.FirstOrDefault(); if (string.IsNullOrEmpty(processKey)) { session.SendResponse("No parameter!"); return; } if (int.TryParse(processKey, out processId)) { Process process = Process.GetProcessById(processId); if (process != null) { process.Kill(); session.SendResponse("The specific process has been killed!"); return; } else { session.SendResponse("The specific process does not exist!"); } } else { List <Process> processes = Process.GetProcesses().Where(p => p.ProcessName.Equals(processKey, StringComparison.OrdinalIgnoreCase)).ToList(); processes.ForEach(p => p.Kill()); if (processes.Count <= 0) { session.SendResponse("The specific process does not exist!"); } else if (processes.Count == 1) { session.SendResponse("The specific process has been killed!"); } else { session.SendResponse(string.Format("The {0} specific process has been killed!", processes.Count)); } } }
public override void ExecuteCommand(AppSession session, StringCommandInfo commandData) { //Your code }
public abstract void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo);
public override void ExecuteCommand(RemoteProcessSession session, StringCommandInfo commandData) { var server = session.AppServer; string firstParam = commandData.GetFirstParam(); if (string.IsNullOrEmpty(firstParam)) { session.SendResponse("Invalid parameter!"); return; } var param = commandData[1]; if ("list".Equals(firstParam, StringComparison.OrdinalIgnoreCase)) { StringBuilder sb = new StringBuilder(); foreach (var p in server.GetFrozedProcesses()) { sb.AppendLine(p); } sb.AppendLine(); session.SendResponse(sb.ToString()); return; } else if ("add".Equals(firstParam, StringComparison.OrdinalIgnoreCase)) { if (string.IsNullOrEmpty(param)) { session.SendResponse("Invalid parameter!"); return; } server.AddFrozedProcess(param); session.SendResponse(string.Format("Frozed process {0} has been added!", param)); return; } else if ("remove".Equals(firstParam, StringComparison.OrdinalIgnoreCase)) { if (string.IsNullOrEmpty(param)) { session.SendResponse("Invalid parameter!"); return; } server.RemoveFrozedProcess(param); session.SendResponse(string.Format("Frozed process {0} has been removed!", param)); return; } else if ("clear".Equals(firstParam, StringComparison.OrdinalIgnoreCase)) { server.ClearFrozedProcess(); session.SendResponse("All frozed process have been removed!"); return; } else if ("stop".Equals(firstParam, StringComparison.OrdinalIgnoreCase)) { server.StopFroze(); session.SendResponse("Frozing has been stopped!"); return; } else if ("start".Equals(firstParam, StringComparison.OrdinalIgnoreCase)) { server.StartFroze(); session.SendResponse("Frozing has been started!"); return; } }
public override void ExecuteCommand(AppSession session, StringCommandInfo commandInfo) { ((MyAppServerA)session.AppServer).DespatchMessage(commandInfo[0], commandInfo[1]); }
public override void HandleUnknownCommand(StringCommandInfo cmdInfo) { SendResponse(string.Format(UnknownCommandMessageFormat, cmdInfo.Key)); }
public override void ExecuteCommand(TestSession session, StringCommandInfo commandInfo) { session.SendResponse(commandInfo.Data); }
public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo) { session.Close(); }
public override void ExecuteCommand(TrieTreeSession session, StringCommandInfo commandInfo) { Console.WriteLine("receive command HeartJump"); session.SendResponse("1"); Console.WriteLine("HeartJump returns: 1"); }
public override void ExecuteCommand(RemoteProcessSession session, StringCommandInfo commandData) { session.SendResponse("bye"); session.Close(); }
public override void ExecuteCommand(BroadcastSession session, StringCommandInfo commandData) { session.DeviceNumber = commandData[0]; session.AppServer.RegisterNewSession(session); session.SendResponse("100 Connected"); }
public override void ExecuteCommand(TestSession session, StringCommandInfo commandData) { Console.WriteLine("R:" + commandData.Data); session.SendResponse(commandData.Data); }
public override void HandleUnknownCommand(StringCommandInfo cmdInfo) { //Console.WriteLine("Unknow command: '{0}'", cmdInfo.Key); }
public override void ExecuteCommand(TestSession session, StringCommandInfo commandData) { session.SendResponse(string.Format(ReplyFormat, commandData.Data)); }