NAP
udpserver.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 <thread>
10 #include <mutex>
11 
12 // NAP includes
13 #include <nap/numeric.h>
14 #include <concurrentqueue.h>
15 #include <nap/signalslot.h>
16 
17 // Local includes
18 #include "udpadapter.h"
19 #include "udppacket.h"
20 
21 namespace nap
22 {
28  class NAPAPI UDPServer final : public UDPAdapter
29  {
30  RTTI_ENABLE(UDPAdapter)
31  public:
35  UDPServer();
36 
40  virtual ~UDPServer();
41 
46  void registerListenerSlot(Slot<const UDPPacket&>& slot);
47 
52  void removeListenerSlot(Slot<const UDPPacket&>& slot);
53 
54  int mPort = 13251;
55  std::string mIPAddress = "";
56  std::vector<std::string> mMulticastGroups;
57  protected:
62 
68  virtual bool onStart(utility::ErrorState& errorState) override final;
69 
73  virtual void onStop() override final;
74 
78  void onProcess() override final;
79  private:
80  // Server specific ASIO implementation
81  class Impl;
82  std::unique_ptr<Impl> mImpl;
83 
84  // mutex
85  std::mutex mMutex;
86  };
87 }
nap::Slot
Slot.
Definition: signalslot.h:21
nap::utility::ErrorState
Definition: errorstate.h:19
nap::Signal
Definition: signalslot.h:28
nap::UDPServer
Definition: udpserver.h:28
nap::UDPAdapter
Definition: udpadapter.h:25
nap::UDPServer::packetReceived
Signal< const UDPPacket & > packetReceived
Definition: udpserver.h:61
nap
Definition: templateapp.h:17
nap::UDPServer::mMulticastGroups
std::vector< std::string > mMulticastGroups
Property: 'Multicast Groups' multicast groups to join.
Definition: udpserver.h:56