Skip to content

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

@camegone

Description

@camegone

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();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions