Beispiel #1
0
        // 外部输入流监听服务
        private static void startProcReadMsg()
        {
            NamedPipeServerStream pipeIn = new NamedPipeServerStream(ptag, PipeDirection.InOut, 254);

            while (keeprun)
            {
                pipeIn.WaitForConnection();
                StreamReader reader = new StreamReader(pipeIn);
                string       line   = reader.ReadLine();
                if (!string.IsNullOrEmpty(line))
                {
                    // 消息处理
                    string [] cmds = line.Split(',');
                    if (cmds.Length > 1)
                    {
                        string curstrr = line.Substring(line.IndexOf(',') + 1);
                        switch (cmds[0])
                        {
                        case TAG_CMD:
                            if (!string.IsNullOrEmpty(curstrr))
                            {
                                if (curstrr == "BANUPDATE")
                                {
                                    // 更新banlist
                                    reloadBanlist();
                                }
                                else
                                {
                                    sendCommand(procname, curstrr);
                                }
                            }
                            break;

                        case TAG_REFRESH:
                            sendFarMessage(curstrr, procstr);
                            break;

                        case TAG_STOP:
                            keeprun = false;
                            KEEPRUN = false;
                            break;
                            //... to do other case
                        }
                    }
                }
                pipeIn.Disconnect();
            }
            // 监听服务结束时,结束正在运行的应用程序
            if (chatservice != null)
            {
                chatunregister();
                chatservice.stopListen();
                chatservice = null;
            }
            closeProc(procname);
        }
Beispiel #2
0
 void StopcmdClick(object sender, EventArgs e)
 {
     telloController.stopListen();
     startCmd.Enabled = true;
     cmdStoped        = true;
 }