BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
GWSOptimisticExporter.h
1 #pragma once
2 
3 #include <set>
4 
5 #include <Poco/AtomicCounter.h>
6 #include <Poco/Mutex.h>
7 
8 #include "core/Exporter.h"
9 #include "gwmessage/GWMessage.h"
10 #include "server/GWSConnector.h"
11 #include "server/GWSListener.h"
12 #include "util/Loggable.h"
13 
14 namespace BeeeOn {
15 
26  public Exporter,
27  public GWSListener,
28  Loggable {
29 public:
30  typedef Poco::SharedPtr<GWSOptimisticExporter> Ptr;
31 
33 
34  void setConnector(GWSConnector::Ptr connector);
35  void setExportNonConfirmed(int count);
36 
46  bool ship(const SensorData &data) override;
47 
51  void onOther(const GWMessage::Ptr message) override;
52 
56  void onConnected(const GWSListener::Address &) override;
57 
61  void onDisconnected(const GWSListener::Address &) override;
62 
63 private:
64  size_t m_exportNonConfirmed;
65  GWSConnector::Ptr m_connector;
66  Poco::AtomicCounter m_connected;
67  std::set<GlobalID> m_exported;
68  Poco::FastMutex m_lock;
69 };
70 
71 }
Definition: SensorData.h:20
void onOther(const GWMessage::Ptr message) override
Process confirmations of exported data.
Definition: GWSOptimisticExporter.cpp:69
Definition: Exporter.h:11
GWSOptimisticExporter implements exporting via GWSConnector. It wraps the given SensorData instances ...
Definition: GWSOptimisticExporter.h:25
Definition: GWSListener.h:23
void onDisconnected(const GWSListener::Address &) override
Notice that the GWSConnector is disconnected.
Definition: GWSOptimisticExporter.cpp:84
Definition: Loggable.h:19
bool ship(const SensorData &data) override
Ship the given data via GWSConnector::send() to the remote server. The connectivity status of the GWS...
Definition: GWSOptimisticExporter.cpp:37
GWSListener provides an interface for delivering of events and messages related to communication with...
Definition: GWSListener.h:19
void onConnected(const GWSListener::Address &) override
Notice that the GWSConnector is connected.
Definition: GWSOptimisticExporter.cpp:79