mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 19:48:03 +00:00
Improving AutoDiscovery
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "APConfig.h"
|
||||
#include "StorageService.h"
|
||||
#include "APConfig.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
#include "AutoDiscovery.h"
|
||||
#include "framework/uCentral_Protocol.h"
|
||||
#include "framework/KafkaTopics.h"
|
||||
#include "storage/storage_inventory.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/MicroService.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
|
||||
@@ -84,10 +84,9 @@ namespace OpenWifi{
|
||||
ProvObjects::InventoryTagVec Tags;
|
||||
StorageService()->InventoryDB().GetRecords(0,100,Tags," subscriber='" + Arg + "'");
|
||||
if(SerialOnly) {
|
||||
std::vector<std::string> DeviceList;
|
||||
for(const auto &i:Tags)
|
||||
DeviceList.push_back(i.serialNumber);
|
||||
return ReturnObject("serialNumbers",DeviceList);
|
||||
std::vector<std::string> SerialNumbers;
|
||||
std::transform(cbegin(Tags), cend(Tags), std::back_inserter(SerialNumbers), [](const auto &T) { return T.serialNumber; });
|
||||
return ReturnObject("serialNumbers",SerialNumbers);
|
||||
} else {
|
||||
return MakeJSONObjectArray("taglist", Tags, *this);
|
||||
}
|
||||
|
||||
@@ -17,17 +17,22 @@ namespace OpenWifi {
|
||||
|
||||
class MyParallelSocketReactor {
|
||||
public:
|
||||
MyParallelSocketReactor() {
|
||||
explicit MyParallelSocketReactor(unsigned NumReactors=8) :
|
||||
NumReactors_(NumReactors)
|
||||
{
|
||||
Reactors_ = new Poco::Net::SocketReactor[NumReactors_];
|
||||
for(int i=0;i<NumReactors_;i++) {
|
||||
Threads_[i].start(Reactors_[i]);
|
||||
ReactorPool_.start(Reactors_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
~MyParallelSocketReactor() {
|
||||
for(int i=0;i<NumReactors_;i++) {
|
||||
Reactors_[i].stop();
|
||||
Threads_[i].join();
|
||||
}
|
||||
ReactorPool_.stopAll();
|
||||
ReactorPool_.joinAll();
|
||||
delete [] Reactors_;
|
||||
}
|
||||
|
||||
Poco::Net::SocketReactor & Reactor() {
|
||||
@@ -35,9 +40,9 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
private:
|
||||
unsigned NumReactors_=8;
|
||||
std::array<Poco::Net::SocketReactor,8> Reactors_;
|
||||
std::array<Poco::Thread,8> Threads_;
|
||||
unsigned NumReactors_;
|
||||
Poco::Net::SocketReactor * Reactors_;
|
||||
Poco::ThreadPool ReactorPool_;
|
||||
};
|
||||
|
||||
class WebSocketClient;
|
||||
@@ -87,9 +92,9 @@ namespace OpenWifi {
|
||||
|
||||
class WebSocketClient {
|
||||
public:
|
||||
explicit WebSocketClient( Poco::Net::WebSocket & WS , const std::string Id, Poco::Logger & L) :
|
||||
explicit WebSocketClient( Poco::Net::WebSocket & WS , const std::string &Id, Poco::Logger & L) :
|
||||
Reactor_(WebSocketClientServer()->ReactorPool().Reactor()),
|
||||
Id_(std::move(Id)),
|
||||
Id_(Id),
|
||||
Logger_(L) {
|
||||
try {
|
||||
WS_ = std::make_unique<Poco::Net::WebSocket>(WS);
|
||||
|
||||
Reference in New Issue
Block a user