Move text message handling into the new plugin system

This commit is contained in:
Kevin Hester
2020-11-28 12:10:19 +08:00
parent ddab4a0235
commit 0b0d293a66
16 changed files with 223 additions and 59 deletions

22
src/mesh/MeshPlugin.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include "MeshPlugin.h"
#include <assert.h>
std::vector<MeshPlugin *> MeshPlugin::plugins;
MeshPlugin::MeshPlugin(const char *_name) : name(_name) {
plugins.push_back(this);
}
MeshPlugin::~MeshPlugin()
{
assert(0); // FIXME - remove from list of plugins once someone needs this feature
}
void MeshPlugin::callPlugins(const MeshPacket &mp)
{
for (auto i = plugins.begin(); i != plugins.end(); ++i) {
if ((*i)->wantPortnum(mp.decoded.data.portnum))
if ((*i)->handleReceived(mp))
break;
}
}