|
@@ -18,10 +18,6 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
bool ExpelPlugin::StartTask(){
|
|
|
- // timer
|
|
|
- // if(this->timer0 == nullptr) this->timer0 = std::make_shared<Timer>(10.0f, [&](){
|
|
|
- // return true;
|
|
|
- // }, nullptr);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -30,7 +26,8 @@ namespace gsd
|
|
|
* @return {*}
|
|
|
*/
|
|
|
bool ExpelPlugin::Alive(){
|
|
|
- return true;
|
|
|
+ if(this->sockerUdp == nullptr) this->PluginAlive = false;
|
|
|
+ return this->PluginAlive;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -47,6 +44,7 @@ namespace gsd
|
|
|
bool ExpelPlugin::Init(){
|
|
|
if(this->sockerUdp == nullptr) this->sockerUdp = Socket::createSocket();
|
|
|
if(this->sockerUdp == nullptr) {
|
|
|
+ this->PluginAlive = false;
|
|
|
ErrorL << "Sockerudp cannot be created" << endl;
|
|
|
return false;
|
|
|
}
|
|
@@ -55,6 +53,7 @@ namespace gsd
|
|
|
this->sockerUdp->setOnRead([&](const Buffer::Ptr &buf, struct sockaddr *addr , int){
|
|
|
this->UdpRecData(buf);
|
|
|
});
|
|
|
+ this->PluginAlive = true;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -129,4 +128,28 @@ namespace gsd
|
|
|
int32_t ExpelPlugin::getExpelSize(){
|
|
|
return Expel::getPtr()->getExpelSize();
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: RestPlugin
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ bool ExpelPlugin::RestPlugin(){
|
|
|
+ auto task = [&](){
|
|
|
+ if(this->sockerUdp != nullptr){
|
|
|
+ this->sockerUdp->bindUdpSock(7777);
|
|
|
+ this->sockerUdp->setOnRead([&](const Buffer::Ptr &buf, struct sockaddr *addr , int){
|
|
|
+ this->UdpRecData(buf);
|
|
|
+ });
|
|
|
+ this->PluginAlive = true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if(this->sockerUdp == nullptr) this->sockerUdp = Socket::createSocket();
|
|
|
+ if(this->sockerUdp == nullptr) {
|
|
|
+ this->PluginAlive = false;
|
|
|
+ ErrorL << "Sockerudp cannot be created" << endl;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ task();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
} // namespace gsd
|