mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
This PR also uses the newly added -default-branch flag to generate the list of changed files with respect to the correct branch (2027).
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
// Copyright (c) FIRST and other WPILib contributors.
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
// the WPILib BSD license file in the root directory of this project.
|
|
|
|
#include "wpi/net/DsClient.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <memory>
|
|
|
|
#include "wpi/net/EventLoopRunner.hpp"
|
|
#include "wpi/util/Logger.hpp"
|
|
#include "wpi/util/print.hpp"
|
|
|
|
namespace uv = wpi::net::uv;
|
|
|
|
static void logfunc(unsigned int level, const char* file, unsigned int line,
|
|
const char* msg) {
|
|
std::fprintf(stderr, "(%d) %s:%d: %s\n", level, file, line, msg);
|
|
}
|
|
|
|
int main() {
|
|
wpi::util::Logger logger{logfunc, 0};
|
|
|
|
// Kick off the event loop on a separate thread
|
|
wpi::net::EventLoopRunner loop;
|
|
std::shared_ptr<wpi::net::DsClient> client;
|
|
loop.ExecAsync([&](uv::Loop& loop) {
|
|
client = wpi::net::DsClient::Create(loop, logger);
|
|
client->setIp.connect(
|
|
[](std::string_view ip) { wpi::util::print("got IP: {}\n", ip); });
|
|
client->clearIp.connect([] { std::fputs("cleared IP\n", stdout); });
|
|
});
|
|
|
|
// wait for a keypress to terminate
|
|
static_cast<void>(std::getchar());
|
|
}
|