modify codes.

This commit is contained in:
pandx 2025-01-22 19:06:01 +08:00
parent 493da71a81
commit 83a892465c
6 changed files with 24 additions and 13 deletions

View File

@ -1,3 +1,6 @@
#include <fstream>
#include "zlog.h"
#include "communication_cmd.hpp"
#include "localserver/local_server.hpp"
#include "common/common_func.hpp"
@ -5,8 +8,6 @@
#include <boost/algorithm/string.hpp>
#include "dbaccess/sql_db.hpp"
#include "scheduler/schedule.hpp"
#include "zlog.h"
#include <fstream>
extern zlog_category_t *zct;

View File

@ -1,8 +1,9 @@
#include <string.h>
#include "zlog.h"
#include "local_server.hpp"
#include "jsonparse/communication_cmd.hpp"
#include "common/global.hpp"
#include <string.h>
#include "zlog.h"
extern zlog_category_t *zct;

View File

@ -11,6 +11,7 @@
extern zlog_category_t *zct;
void CMTSession::start() {
data_ = (char*)malloc(CMT_TCP_LEN);
memset(data_, 0, CMT_TCP_LEN);
sessionSet_.insert(shared_from_this()); // 将会话添加到会话集合中
do_read();

View File

@ -188,6 +188,11 @@ public:
version_ = 1;
head_len_ = sizeof(PackageHead);
}
~CMTSession() {
if (data_ != nullptr) {
free(data_);
}
}
void start();
void set_data(char *data, int len);
@ -198,7 +203,7 @@ private:
tcp::socket socket_;
std::unordered_set<std::shared_ptr<CMTSession>>& sessionSet_;
char data_[CMT_TCP_LEN];
char *data_;
std::string web_version_;
int version_;
int head_len_;

View File

@ -116,9 +116,6 @@ int main(int argc, char *argv[]) {
boost::thread startTcpCgi(attrs, StartCgiServer);
startTcpCgi.detach();
// //启动CMT server
// boost::thread startTcpCmt(attrs, StartCMTServer);
// startTcpCmt.detach();
sleep(5);
uart_inst::instance().ZigbeeParameterConfig();
@ -141,6 +138,10 @@ int main(int argc, char *argv[]) {
zlog_error(zbt, "(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)");
}
//启动CMT server
boost::thread startTcpCmt(attrs, StartCMTServer);
startTcpCmt.detach();
int fd = OpenWatchDog();
int count = 0;
while (GlobalConfig::QuitFlag_G) {

View File

@ -1,5 +1,6 @@
#include "thread_func.hpp"
#include <map>
#include <memory>
#include <time.h>
#include <math.h>
#include <string.h>
@ -21,7 +22,6 @@
#include "utility/search_dev.hpp"
#include "localserver/local_server.hpp"
#include "localserver/cmt_server.hpp"
#include <memory>
extern zlog_category_t *zct;
@ -31,6 +31,8 @@ static std::string serverPort;
Dial dial;
static int clean_memory = 0;
std::unique_ptr<CMTServer> g_mgr_server;
void StartCgiServer() {
zlog_info(zbt, "start deal cgi");
@ -40,8 +42,8 @@ void StartCgiServer() {
}
}
std::unique_ptr<CMTServer> g_mgr_server;
void StartCMTServer() {
sleep(2);
boost::asio::io_service io_service;
g_mgr_server = std::make_unique<CMTServer>(io_service, 10000); io_service.run();
}