コード例 #1
0
ファイル: LIST.cs プロジェクト: sandeep526/NewUG12
        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());
        }
コード例 #2
0
ファイル: ECHO.cs プロジェクト: prabhamotti/ResumeView
 public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo)
 {
     foreach (var p in commandInfo.Parameters)
     {
         session.SendResponse(p);
     }
 }
コード例 #3
0
ファイル: ECHO.cs プロジェクト: sandeep526/NewUG12
 public override void ExecuteCommand(YourSession session, StringCommandInfo commandData)
 {
     foreach (var p in commandData.Parameters)
     {
         session.SendResponse(p);
     }
 }
コード例 #4
0
ファイル: ECHO.cs プロジェクト: RolfEleveld/TryoutCSharp
 public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo)
 {
     foreach(var p in commandInfo.Parameters)
     {
         session.SendResponse(p);
     }
 }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: BROA.cs プロジェクト: sandeep526/NewUG12
        public override void ExecuteCommand(BroadcastSession session, StringCommandInfo commandData)
        {
            string message = commandData.Data;

            session.AppServer.BroadcastMessage(session, message);
            session.SendResponse("101 message broadcasted");
        }
コード例 #7
0
ファイル: PARA.cs プロジェクト: windygu/SuperSocket-1
 public override void ExecuteCommand(TestSession session, StringCommandInfo commandData)
 {
     foreach (var p in commandData.Parameters)
     {
         Console.WriteLine("S: " + p);
         session.SendResponse(p);
     }
 }
コード例 #8
0
ファイル: RECEM.cs プロジェクト: sandeep526/NewUG12
        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);
        }
コード例 #9
0
ファイル: RECEL.cs プロジェクト: windygu/SuperSocket-1
        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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        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));
                }
            }
        }
コード例 #12
0
 public override void ExecuteCommand(AppSession session, StringCommandInfo commandData)
 {
     //Your code
 }
コード例 #13
0
 public abstract void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo);
コード例 #14
0
        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;
            }
        }
コード例 #15
0
ファイル: DESP.cs プロジェクト: xxjeng/nuxleus
 public override void ExecuteCommand(AppSession session, StringCommandInfo commandInfo)
 {
     ((MyAppServerA)session.AppServer).DespatchMessage(commandInfo[0], commandInfo[1]);
 }
コード例 #16
0
ファイル: TestSession.cs プロジェクト: sandeep526/NewUG12
 public override void HandleUnknownCommand(StringCommandInfo cmdInfo)
 {
     SendResponse(string.Format(UnknownCommandMessageFormat, cmdInfo.Key));
 }
コード例 #17
0
ファイル: ECHO.cs プロジェクト: anthrax3/testlab
 public override void ExecuteCommand(TestSession session, StringCommandInfo commandInfo)
 {
     session.SendResponse(commandInfo.Data);
 }
コード例 #18
0
ファイル: QUIT.cs プロジェクト: prabhamotti/ResumeView
 public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo)
 {
     session.Close();
 }
コード例 #19
0
 public override void ExecuteCommand(TrieTreeSession session, StringCommandInfo commandInfo)
 {
     Console.WriteLine("receive command HeartJump");
     session.SendResponse("1");
     Console.WriteLine("HeartJump returns: 1");
 }
コード例 #20
0
ファイル: QUIT.cs プロジェクト: sandeep526/NewUG12
 public override void ExecuteCommand(RemoteProcessSession session, StringCommandInfo commandData)
 {
     session.SendResponse("bye");
     session.Close();
 }
コード例 #21
0
ファイル: CONN.cs プロジェクト: windygu/SuperSocket-1
 public override void ExecuteCommand(BroadcastSession session, StringCommandInfo commandData)
 {
     session.DeviceNumber = commandData[0];
     session.AppServer.RegisterNewSession(session);
     session.SendResponse("100 Connected");
 }
コード例 #22
0
 public override void ExecuteCommand(TestSession session, StringCommandInfo commandData)
 {
     Console.WriteLine("R:" + commandData.Data);
     session.SendResponse(commandData.Data);
 }
コード例 #23
0
 public override void HandleUnknownCommand(StringCommandInfo cmdInfo)
 {
     //Console.WriteLine("Unknow command: '{0}'", cmdInfo.Key);
 }
コード例 #24
0
ファイル: QUERY.cs プロジェクト: xxjeng/nuxleus
 public override void ExecuteCommand(AppSession session, StringCommandInfo commandData)
 {
     //Your code
 }
コード例 #25
0
ファイル: DESP.cs プロジェクト: sandeep526/NewUG12
 public override void ExecuteCommand(AppSession session, StringCommandInfo commandInfo)
 {
     ((MyAppServerA)session.AppServer).DespatchMessage(commandInfo[0], commandInfo[1]);
 }
コード例 #26
0
 public override void ExecuteCommand(TestSession session, StringCommandInfo commandData)
 {
     session.SendResponse(string.Format(ReplyFormat, commandData.Data));
 }