vrchat-community / vrc-oscquery-lib

OSCQuery library in .NET
MIT License
48 stars 9 forks source link

Method realization of OSCQueryserviceBuilder.WithDefaults() is confusing #40

Open camegone opened 1 year ago

camegone commented 1 year ago

The WithDefaults() method actually activates http server and not change server name and ports configuration, while its name suggest "just set default values for later activation". So, in current library, this code is wrong (this one is similar to the example code in Getting started Doc.):

var myBadService = new new OSCQueryServiceBuilder()
            .WithDefaults() // At this time, a http server has been activated at default configuration.
            // Methods below are only change class' property, and information in the server is not going to be changed.
            .WithTcpPort(Extensions.GetAvailableTcpPort()) 
            .WithUdpPort(Extensions.GetAvailableUdpPort())
            .WithServiceName("MySuperDuperService")
            .Build();

... and this is the version works fine:

var myGoodService = new OSCQueryServiceBuilder()
            // First, modify class' properties.
            .WithTcpPort(Extensions.GetAvailableTcpPort())
            .WithUdpPort(Extensions.GetAvailableUdpPort())
            .WithServiceName("MySuperDuperService")
            // Then activate server with this function
            .WithDefaults()
            .Build();
cygami-vr commented 1 year ago

A couple of more minor documentation issues I noticed to add on to this (let me know if I should open these as separate issues). Also, a disclaimer as I'm a novice at C# development, I'm mostly experienced with Java but the only Java OSCQuery implementation I could find was never fully implemented.

  1. Since we have to build the vrc-oscquery-lib.dll ourselves, it would be helpful to also list the dependencies needed to build the vrc-oscquery-lib.dll. I had to find these by trial and error with every build failure.
  2. The "Testing with VRChat" section in the readme.md mentions the TCP service being available at http://localhost:9001/ by default, but this is incorrect, 9001 is a UDP/OSC port by default.

I did try implementing OSCQuery myself using the jmDNS library for the mDNS portion, but VRChat would never seem to recognize my service. So, I would also like to see it clarified what VRChat is looking for when finding eligible services. The main two differences I noticed in my service and what the vrc-oscquery-lib creates is that the address was my machine's internal IP address instead of 127.0.0.1 (even though these are effectively the same), and that my service was just under the "local" domain instead of "osc.local" or "oscjson.local". I could not find a way in the jmDNS library to change either of these in my advertised service.

Myrkie commented 2 months ago
var myGoodService = new OSCQueryServiceBuilder()
            // First, modify class' properties.
            .WithTcpPort(Extensions.GetAvailableTcpPort())
            .WithUdpPort(Extensions.GetAvailableUdpPort())
            .WithServiceName("MySuperDuperService")
            // Then activate server with this function
            .WithDefaults()
            .Build();

this needs to be more well known, spent actual hours trying to get this to work only to find out this was the issue, please fix this or make it more obvious in documentation.