Skip to content

Configuring the client

ServerConfiguration is the single value you pass to SwiftSonicClient at creation time. It bundles everything the client needs to talk to a server: where it lives, who you are, and how the HTTP plumbing should behave.

let config = ServerConfiguration(
host: "music.example.com",
username: "user",
password: "pass"
)
let client = SwiftSonicClient(config: config)
  • host — server hostname or full URL.
  • username / password — credentials used to derive the per-request token.

TODO: confirm whether host accepts a bare hostname, a scheme-prefixed URL, or both. Verify behaviour around trailing slashes and ports against Sources/SwiftSonic/ServerConfiguration.swift.

ServerConfiguration exposes several optional properties for transport and behaviour tuning:

TODO: enumerate the full list of optional ServerConfiguration parameters with their defaults once verified in source.

SwiftSonicClient is an actor and is safe to share across tasks. Create one instance per logical server connection and reuse it.