48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
|
|
/*
|
||
|
|
* vccli — headless test client.
|
||
|
|
*
|
||
|
|
* This is the primary way the protocol is exercised and verified from M1 onward (see
|
||
|
|
* AGENTS.md). Each milestone's exit criterion is demonstrated by driving two vccli
|
||
|
|
* instances against a real voicecat-server. Today it just shows the C ABI is linkable.
|
||
|
|
*/
|
||
|
|
#include <cstdio>
|
||
|
|
|
||
|
|
#include "voicecat.h"
|
||
|
|
|
||
|
|
namespace {
|
||
|
|
|
||
|
|
void on_event(void* /*user*/, const vc_event* ev) {
|
||
|
|
std::printf("[event] type=%d state=%d result=%d text=%s\n", ev->type, ev->connection_state,
|
||
|
|
ev->result, ev->text ? ev->text : "");
|
||
|
|
}
|
||
|
|
|
||
|
|
} // namespace
|
||
|
|
|
||
|
|
int main(int argc, char** argv) {
|
||
|
|
std::printf("vccli — VoiceCat test client (core %s, protocol v%d)\n", vc_version_string(),
|
||
|
|
VOICECAT_PROTOCOL_VERSION);
|
||
|
|
|
||
|
|
vc_config cfg{};
|
||
|
|
cfg.client_name = "vccli";
|
||
|
|
cfg.client_version = vc_version_string();
|
||
|
|
cfg.log_level = VC_LOG_INFO;
|
||
|
|
|
||
|
|
vc_callbacks cb{};
|
||
|
|
cb.on_event = on_event;
|
||
|
|
|
||
|
|
vc_client* c = vc_client_create(&cfg, cb);
|
||
|
|
if (c == nullptr) {
|
||
|
|
std::fprintf(stderr, "failed to create client\n");
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
// M0: demonstrate the call surface. These return VC_ERR_NOT_IMPLEMENTED for now.
|
||
|
|
const char* host = (argc > 1) ? argv[1] : "127.0.0.1";
|
||
|
|
vc_result r = vc_connect(c, host, 8384);
|
||
|
|
std::printf("vc_connect(%s:8384) -> %d (%s)\n", host, r, vc_result_string(r));
|
||
|
|
|
||
|
|
vc_client_destroy(c);
|
||
|
|
std::printf("ok\n");
|
||
|
|
return 0;
|
||
|
|
}
|