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();
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.):
... and this is the version works fine: