blob: 69c1061fdd2a39ad4be5ae34dc8660c99e87889f [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#include <cstdio>
6
7#include "fmt/format.h"
8#include "wpi/DsClient.h"
9#include "wpi/EventLoopRunner.h"
10#include "wpi/Logger.h"
11#include "wpi/uv/Error.h"
12
13namespace uv = wpi::uv;
14
15static void logfunc(unsigned int level, const char* file, unsigned int line,
16 const char* msg) {
17 std::fprintf(stderr, "(%d) %s:%d: %s\n", level, file, line, msg);
18}
19
20int main() {
21 wpi::Logger logger{logfunc, 0};
22
23 // Kick off the event loop on a separate thread
24 wpi::EventLoopRunner loop;
25 std::shared_ptr<wpi::DsClient> client;
26 loop.ExecAsync([&](uv::Loop& loop) {
27 client = wpi::DsClient::Create(loop, logger);
28 client->setIp.connect(
29 [](std::string_view ip) { fmt::print("got IP: {}\n", ip); });
30 client->clearIp.connect([] { std::fputs("cleared IP\n", stdout); });
31 });
32
33 // wait for a keypress to terminate
34 std::getchar();
35}