Skip to content

Commit

Permalink
Added ability to use any port in vars.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey004 committed Mar 30, 2023
1 parent 4212a8f commit 88dd729
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Quest2-VRC/Services/Check_Vars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static void CheckVars()
Console.WriteLine("vars.txt does not exist, creating...");
string[] lines =
{
"HMDBat = HMDBat", "ControllerBatL = ControllerBatL", "ControllerBatR = ControllerBatR", "Receive_addr = /avatar/parameters/Eyes mode", "Receive_addr_test = /avatar/parameters/Eyes_mode" // Default settings for my avatar
"HMDBat = HMDBat", "ControllerBatL = ControllerBatL", "ControllerBatR = ControllerBatR", "Receive_addr = /avatar/parameters/Eyes mode", "Receive_addr_test = /avatar/parameters/Eyes_mode", "SendPort = 9000", "ReceivePort = 9001" // Default settings for my avatar
};
File.WriteAllLines("vars.txt", lines);
}
Expand Down
11 changes: 9 additions & 2 deletions Quest2-VRC/Services/PacketSender.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Bespoke.Osc;
using System;
using System.IO;
using System.Linq;
using System.Net;
using static Quest2_VRC.Logger;

Expand All @@ -11,11 +13,16 @@ public class PacketSender


static public IPAddress IP = IPAddress.Loopback;
static readonly int Port = 9000;
static readonly IPEndPoint VRChat = new IPEndPoint(IP, Port);



static public void SendPacket(params VRChatMessage[] Params)
{
var dic = File.ReadAllLines("vars.txt")
.Select(l => l.Split(new[] { '=' }))
.ToDictionary(s => s[0].Trim(), s => s[1].Trim());
int SendPort = int.Parse(dic["SendPort"]);
IPEndPoint VRChat = new IPEndPoint(IP, SendPort);
foreach (var Param in Params)
{
try
Expand Down
6 changes: 4 additions & 2 deletions Quest2-VRC/Services/Receiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Receiver

{
static readonly int dataInt = 0;
static readonly int Port = 9001;

public static async void Run()
{
RGBControler.SendRGBData(dataInt); //Init OpenRGB
Expand All @@ -22,8 +22,10 @@ public static async void Run()
.ToDictionary(s => s[0].Trim(), s => s[1].Trim());
string Eyesmode = dic["Receive_addr"];
string EyesmodeTest = dic["Receive_addr_test"];
int ReceivePort = int.Parse(dic["ReceivePort"]);

OscServer oscServer;
oscServer = new OscServer((Bespoke.Common.Net.TransportType)TransportType.Udp, IP, Port);
oscServer = new OscServer((Bespoke.Common.Net.TransportType)TransportType.Udp, IP, ReceivePort);
oscServer.FilterRegisteredMethods = true;
oscServer.RegisterMethod(Eyesmode);
oscServer.RegisterMethod(EyesmodeTest);
Expand Down

0 comments on commit 88dd729

Please sign in to comment.