diff --git a/examples/tui_client/README.md b/examples/tui_client/README.md index ae0e4e1b..2c1a71ee 100644 --- a/examples/tui_client/README.md +++ b/examples/tui_client/README.md @@ -44,6 +44,7 @@ brew install portaudio ./build/examples/tui_client/tui_client "My Player" # custom name ./build/examples/tui_client/tui_client -u ws://192.168.1.10:8928/sendspin # connect to a specific server ./build/examples/tui_client/tui_client -p 8930 # listen on a custom port +./build/examples/tui_client/tui_client -a # allow unpaired access ./build/examples/tui_client/tui_client -V # disable visualizer ``` @@ -51,6 +52,6 @@ Press `q` to quit. ## Pairing -The example does not enable unpaired access, so a server has to pair with the client before it can stream. The Server panel shows the connection's trust and, when a server pairs with a code, the six-digit code to enter there. A Pairing Token panel holds the Pairing PSK token to paste into a server that pairs via `pairing_psk`, and disappears once the connection is paired. +By default the example does not enable unpaired access, so a server has to pair with the client before it can stream; with `-a`, a server can stream without pairing once its operator approves the client. The Server panel shows the connection's trust and, when a server pairs with a code, the six-digit code to enter there. A Pairing Token panel holds the Pairing PSK token to paste into a server that pairs via `pairing_psk`, and disappears once the connection is paired. Identity and pairing records are stored in `~/.sendspin_tui.json`, separate from basic_client's file; delete it to re-provision the client from scratch. diff --git a/examples/tui_client/main.cpp b/examples/tui_client/main.cpp index 403fa05f..23be919e 100644 --- a/examples/tui_client/main.cpp +++ b/examples/tui_client/main.cpp @@ -21,8 +21,11 @@ /// name: Optional friendly name (default: "TUI Client") /// /// Options: +/// -u URL Connect to a WebSocket URL (e.g. ws://192.168.1.10:8928/sendspin) /// -p PORT Listen on PORT (default: 8928) /// -f FORMAT Audio format as codec:rate:bits:channels (repeatable) +/// -a Enable unpaired access, so a server can stream without pairing first +/// -V Disable visualizer /// -h Show usage #include "tui.h" @@ -437,6 +440,8 @@ static void print_usage(const char* prog) { fprintf(stderr, " Can be specified multiple times. Codecs: %s\n", SUPPORTED_CODECS); fprintf(stderr, " At least one flac or pcm format is required\n"); + fprintf(stderr, " -a Enable unpaired access, so a server can stream without\n"); + fprintf(stderr, " pairing first\n"); fprintf(stderr, " -V Disable visualizer\n"); fprintf(stderr, " -h Show this help\n"); } @@ -444,11 +449,12 @@ static void print_usage(const char* prog) { int main(int argc, char* argv[]) { // Parse command line options bool enable_visualizer = true; + bool unpaired_access = false; std::string connect_url; uint16_t server_port = DEFAULT_SENDSPIN_PORT; std::vector audio_formats; int opt; - while ((opt = getopt(argc, argv, "u:p:f:Vh")) != -1) { + while ((opt = getopt(argc, argv, "u:p:f:aVh")) != -1) { switch (opt) { case 'u': connect_url = optarg; @@ -468,6 +474,9 @@ int main(int argc, char* argv[]) { audio_formats.push_back(fmt); break; } + case 'a': + unpaired_access = true; + break; case 'V': enable_visualizer = false; break; @@ -576,6 +585,7 @@ int main(int argc, char* argv[]) { SendspinClient client(std::move(config)); client.set_persistence_provider(&persistence_provider); + client.set_unpaired_access_enabled(unpaired_access); // Add roles #ifdef SENDSPIN_ENABLE_PLAYER