Function serveNoise

Create a new vibe-noisestream based API server.

NoiseServer!(Implementation,API) serveNoise(Implementation, API) (
  NoiseSettings settings,
  ushort port
)
if (isServerAPI!(Implementation, NoiseInfo));

NoiseServer!(Implementation,API) serveNoise(Implementation, API) (
  NoiseSettings settings,
  ushort port,
  string address
)
if (isServerAPI!(Implementation, NoiseInfo));

Example

abstract static class API
{
    string someMethod(string name);
}

static class Implementation : API
{
    static Implementation startSession(NoiseInfo info)
    {
        return new Implementation();
    }

    override string someMethod(string name)
    {
        return "Hello " ~ name ~ "!";
    }
}

// See vibe-noisestream for how to generate keys
createKeys("server.key", "server.pub");
createKeys("client.key", "client.pub");

// Need to set settings correctly. See vibe-noisestream documentation
// for more information. It's also possible to use a callback for remote
// key verification.
auto settings = NoiseSettings(NoiseKind.server);
settings.privateKeyPath = Path("server.key");
settings.remoteKeyPath = Path("client.pub");

auto server = serveNoise!(Implementation, API)(settings, 8030);
server.stop();