NAP
udpclient.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // External includes
8 #include <nap/device.h>
9 #include <queue>
10 #include <mutex>
11 
12 // NAP includes
13 #include <utility/threading.h>
14 #include <concurrentqueue.h>
15 
16 // Local includes
17 #include "udpadapter.h"
18 #include "udppacket.h"
19 
20 namespace nap
21 {
25  class NAPAPI UDPClient final : public UDPAdapter
26  {
27  RTTI_ENABLE(UDPAdapter)
28  public:
32  UDPClient();
33 
37  virtual ~UDPClient();
38 
45  void send(const UDPPacket& packet);
46 
52  void send(UDPPacket&& packet);
53 
54  int mPort = 13251;
55  std::string mEndpoint = "10.8.0.3";
56  int mMaxPacketQueueSize = 1000;
57  bool mStopOnMaxQueueSizeExceeded = true;
58  bool mBroadcast = false;
59 
60  protected:
66  bool onStart(utility::ErrorState& errorState) override final;
67 
71  void onStop() override final;
72 
76  void onProcess() override final;
77  private:
78  // Client specific ASIO implementation
79  class Impl;
80  std::unique_ptr<Impl> mImpl;
81  std::vector<nap::uint8> mBuffer;
82 
83  // Threading
84  moodycamel::ConcurrentQueue<UDPPacket> mQueue;
85  };
86 }
nap::UDPClient
Definition: udpclient.h:25
nap::uint8
uint8_t uint8
Definition: numeric.h:16
nap::utility::ErrorState
Definition: errorstate.h:19
nap::UDPAdapter
Definition: udpadapter.h:25
nap
Definition: templateapp.h:17
nap::UDPPacket
Definition: udppacket.h:18