WPILibC++ 2023.4.3-108-ge5452e3
DsClient.h
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/Signal.h>
12
13namespace wpi {
14
15class Logger;
16
17namespace uv {
18class Loop;
19class Tcp;
20class Timer;
21} // namespace uv
22
23class DsClient : public std::enable_shared_from_this<DsClient> {
24 struct private_init {};
25
26 public:
27 static std::shared_ptr<DsClient> Create(wpi::uv::Loop& loop,
28 wpi::Logger& logger) {
29 return std::make_shared<DsClient>(loop, logger, private_init{});
30 }
31
32 DsClient(wpi::uv::Loop& loop, wpi::Logger& logger, const private_init&);
34 DsClient(const DsClient&) = delete;
35 DsClient& operator=(const DsClient&) = delete;
36
37 void Close();
38
41
42 private:
43 void Connect();
44 void HandleIncoming(std::string_view in);
45 void ParseJson();
46
47 wpi::Logger& m_logger;
48
49 std::shared_ptr<wpi::uv::Tcp> m_tcp;
50 std::shared_ptr<wpi::uv::Timer> m_timer;
51
52 std::string m_json;
53};
54
55} // namespace wpi
Definition: DsClient.h:23
sig::Signal clearIp
Definition: DsClient.h:40
sig::Signal< std::string_view > setIp
Definition: DsClient.h:39
static std::shared_ptr< DsClient > Create(wpi::uv::Loop &loop, wpi::Logger &logger)
Definition: DsClient.h:27
DsClient & operator=(const DsClient &)=delete
DsClient(wpi::uv::Loop &loop, wpi::Logger &logger, const private_init &)
DsClient(const DsClient &)=delete
Definition: Logger.h:27
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
Event loop.
Definition: Loop.h:37
basic_string_view< char > string_view
Definition: core.h:520
Definition: AprilTagFieldLayout.h:18