Arg parsing
This commit is contained in:
parent
e99974e754
commit
cf3552a3ae
@ -1,4 +1,5 @@
|
|||||||
using BuildSoft.OscCore;
|
using System.Net;
|
||||||
|
using BuildSoft.OscCore;
|
||||||
|
|
||||||
namespace VRC_Console;
|
namespace VRC_Console;
|
||||||
|
|
||||||
@ -7,7 +8,20 @@ public class OSCCollar
|
|||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
OSCCollar collar = new OSCCollar();
|
OSCCollar collar;
|
||||||
|
if (args.Length == 3)
|
||||||
|
{
|
||||||
|
string ip = args[0];
|
||||||
|
if(!IPAddress.TryParse(args[0], out IPAddress? test) ||
|
||||||
|
!int.TryParse(args[1], out var portReceive) ||
|
||||||
|
!int.TryParse(args[2], out var portSend))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Invalid parameter.\n\rParameters <ip> <receivePort> <sendPort>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
collar = new OSCCollar(ip, portReceive, portSend);
|
||||||
|
}else
|
||||||
|
collar = new OSCCollar();
|
||||||
}
|
}
|
||||||
|
|
||||||
private OscServer Server { get; init; }
|
private OscServer Server { get; init; }
|
||||||
@ -24,10 +38,10 @@ public class OSCCollar
|
|||||||
private static readonly TimeSpan UpdateFieldsTimeout = TimeSpan.FromMilliseconds(1);
|
private static readonly TimeSpan UpdateFieldsTimeout = TimeSpan.FromMilliseconds(1);
|
||||||
private static readonly TimeSpan NilMessageMaxTimeout = TimeSpan.FromMilliseconds(400);
|
private static readonly TimeSpan NilMessageMaxTimeout = TimeSpan.FromMilliseconds(400);
|
||||||
|
|
||||||
private OSCCollar()
|
private OSCCollar(string ip = "127.0.0.1", int portReceive = 9001, int portSend = 9000)
|
||||||
{
|
{
|
||||||
this.Server = new OscServer(9001);
|
this.Server = new OscServer(portReceive);
|
||||||
this.Client = new OscClient("127.0.0.1", 9000);
|
this.Client = new OscClient(ip, portSend);
|
||||||
this._collarAngle = 0;
|
this._collarAngle = 0;
|
||||||
this._collarStretch = 0;
|
this._collarStretch = 0;
|
||||||
Server.TryAddMethod("/avatar/parameters/Collar_Angle", CollarAngleHandle);
|
Server.TryAddMethod("/avatar/parameters/Collar_Angle", CollarAngleHandle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user