WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
DsClient.hpp
Go to the documentation of this file.
1// 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#pragma once
6
7#include <memory>
8#include <string>
9#include <string_view>
10
11#include "wpi/util/Signal.h"
12
13namespace wpi::util {
14class Logger;
15}
16
17namespace wpi::net {
18namespace uv {
19class Loop;
20class Tcp;
21class Timer;
22} // namespace uv
23
24class DsClient : public std::enable_shared_from_this<DsClient> {
25 struct private_init {};
26
27 public:
28 static std::shared_ptr<DsClient> Create(wpi::net::uv::Loop& loop,
29 wpi::util::Logger& logger) {
30 return std::make_shared<DsClient>(loop, logger, private_init{});
31 }
32
34 const private_init&);
36 DsClient(const DsClient&) = delete;
37 DsClient& operator=(const DsClient&) = delete;
38
39 void Close();
40
43
44 private:
45 void Connect();
46 void HandleIncoming(std::string_view in);
47 void ParseJson();
48
49 wpi::util::Logger& m_logger;
50
51 std::shared_ptr<wpi::net::uv::Tcp> m_tcp;
52 std::shared_ptr<wpi::net::uv::Timer> m_timer;
53
54 std::string m_json;
55};
56
57} // namespace wpi::net
DsClient(wpi::net::uv::Loop &loop, wpi::util::Logger &logger, const private_init &)
DsClient(const DsClient &)=delete
static std::shared_ptr< DsClient > Create(wpi::net::uv::Loop &loop, wpi::util::Logger &logger)
Definition DsClient.hpp:28
wpi::util::sig::Signal< std::string_view > setIp
Definition DsClient.hpp:41
DsClient & operator=(const DsClient &)=delete
wpi::util::sig::Signal clearIp
Definition DsClient.hpp:42
Event loop.
Definition Loop.hpp:35
TCP handle.
Definition Tcp.hpp:26
Timer handle.
Definition Timer.hpp:25
Definition Logger.hpp:26
Definition Prepare.hpp:14
Definition raw_socket_ostream.hpp:9
SignalBase< detail::NullMutex, T... > Signal
Specialization of SignalBase to be used in single threaded contexts.
Definition Signal.h:809
Definition raw_os_ostream.hpp:19