コード例 #1
0
ファイル: SendCommand.cs プロジェクト: uoinfusion/Infusion
        public static void Send(string pipeName, string command)
        {
            using (var pipeClient = new NamedPipeClientStream(".", pipeName, PipeDirection.Out, PipeOptions.None))
            {
                Console.WriteLine($"Connecting to './{pipeName}' pipe...");
                pipeClient.Connect();

                Console.WriteLine($"Sending '{command}'");
                var writer = new StreamString(pipeClient);
                writer.WriteString(command);
            }
        }
コード例 #2
0
        public void ListenPipeCommands()
        {
            while (true)
            {
                using (var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.In))
                {
                    pipeServer.WaitForConnection();
                    var ss      = new StreamString(pipeServer);
                    var command = ss.ReadString();

                    if (commandHandler.IsInvocationSyntax(command))
                    {
                        commandHandler.InvokeSyntax(command);
                    }
                    else
                    {
                        infusionProxy.LegacyApi.Say(command);
                    }
                }
            }
        }