VoiceAttack-profiles/plugins/RatAttack-cli/RatAttack-cli.cs

34 lines
1 KiB
C#
Raw Normal View History

2020-10-21 01:13:40 +02:00
#nullable enable
using System;
2020-10-21 01:13:40 +02:00
using System.IO;
using System.IO.Pipes;
namespace RatAttack
{
class RatAttack_cli
{
static void Main(string[] args)
{
RatAttack.Ratsignal ratsignal = new RatAttack.Ratsignal(args[0], args.Length > 1 && args[1] == "true");
2020-10-21 01:13:40 +02:00
using (NamedPipeClientStream pipeClient = new NamedPipeClientStream(".", "RatAttack", PipeDirection.Out))
{
try
2020-10-21 01:13:40 +02:00
{
// try connecting for up to 2minutes; then well assume VoiceAttack just isnt up and wont come up
pipeClient.Connect(120000);
using (StreamWriter writer = new StreamWriter(pipeClient))
{
writer.WriteLine(ratsignal);
}
}
catch (TimeoutException)
{
Console.Error.WriteLine("Connection to RatAttack pipe has timed out.");
2020-10-21 01:13:40 +02:00
}
}
}
}
}