modify codes.
This commit is contained in:
parent
493da71a81
commit
83a892465c
@ -1,3 +1,6 @@
|
|||||||
|
#include <fstream>
|
||||||
|
#include "zlog.h"
|
||||||
|
|
||||||
#include "communication_cmd.hpp"
|
#include "communication_cmd.hpp"
|
||||||
#include "localserver/local_server.hpp"
|
#include "localserver/local_server.hpp"
|
||||||
#include "common/common_func.hpp"
|
#include "common/common_func.hpp"
|
||||||
@ -5,8 +8,6 @@
|
|||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include "dbaccess/sql_db.hpp"
|
#include "dbaccess/sql_db.hpp"
|
||||||
#include "scheduler/schedule.hpp"
|
#include "scheduler/schedule.hpp"
|
||||||
#include "zlog.h"
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
extern zlog_category_t *zct;
|
extern zlog_category_t *zct;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include "zlog.h"
|
||||||
|
|
||||||
#include "local_server.hpp"
|
#include "local_server.hpp"
|
||||||
#include "jsonparse/communication_cmd.hpp"
|
#include "jsonparse/communication_cmd.hpp"
|
||||||
#include "common/global.hpp"
|
#include "common/global.hpp"
|
||||||
#include <string.h>
|
|
||||||
#include "zlog.h"
|
|
||||||
|
|
||||||
extern zlog_category_t *zct;
|
extern zlog_category_t *zct;
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
extern zlog_category_t *zct;
|
extern zlog_category_t *zct;
|
||||||
|
|
||||||
void CMTSession::start() {
|
void CMTSession::start() {
|
||||||
|
data_ = (char*)malloc(CMT_TCP_LEN);
|
||||||
memset(data_, 0, CMT_TCP_LEN);
|
memset(data_, 0, CMT_TCP_LEN);
|
||||||
sessionSet_.insert(shared_from_this()); // 将会话添加到会话集合中
|
sessionSet_.insert(shared_from_this()); // 将会话添加到会话集合中
|
||||||
do_read();
|
do_read();
|
||||||
|
|||||||
@ -188,6 +188,11 @@ public:
|
|||||||
version_ = 1;
|
version_ = 1;
|
||||||
head_len_ = sizeof(PackageHead);
|
head_len_ = sizeof(PackageHead);
|
||||||
}
|
}
|
||||||
|
~CMTSession() {
|
||||||
|
if (data_ != nullptr) {
|
||||||
|
free(data_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
void set_data(char *data, int len);
|
void set_data(char *data, int len);
|
||||||
@ -198,7 +203,7 @@ private:
|
|||||||
|
|
||||||
tcp::socket socket_;
|
tcp::socket socket_;
|
||||||
std::unordered_set<std::shared_ptr<CMTSession>>& sessionSet_;
|
std::unordered_set<std::shared_ptr<CMTSession>>& sessionSet_;
|
||||||
char data_[CMT_TCP_LEN];
|
char *data_;
|
||||||
std::string web_version_;
|
std::string web_version_;
|
||||||
int version_;
|
int version_;
|
||||||
int head_len_;
|
int head_len_;
|
||||||
|
|||||||
7
main.cpp
7
main.cpp
@ -116,9 +116,6 @@ int main(int argc, char *argv[]) {
|
|||||||
boost::thread startTcpCgi(attrs, StartCgiServer);
|
boost::thread startTcpCgi(attrs, StartCgiServer);
|
||||||
startTcpCgi.detach();
|
startTcpCgi.detach();
|
||||||
|
|
||||||
// //启动CMT server
|
|
||||||
// boost::thread startTcpCmt(attrs, StartCMTServer);
|
|
||||||
// startTcpCmt.detach();
|
|
||||||
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
uart_inst::instance().ZigbeeParameterConfig();
|
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)");
|
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 fd = OpenWatchDog();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (GlobalConfig::QuitFlag_G) {
|
while (GlobalConfig::QuitFlag_G) {
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
#include "thread_func.hpp"
|
#include "thread_func.hpp"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -21,7 +22,6 @@
|
|||||||
#include "utility/search_dev.hpp"
|
#include "utility/search_dev.hpp"
|
||||||
#include "localserver/local_server.hpp"
|
#include "localserver/local_server.hpp"
|
||||||
#include "localserver/cmt_server.hpp"
|
#include "localserver/cmt_server.hpp"
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
|
|
||||||
extern zlog_category_t *zct;
|
extern zlog_category_t *zct;
|
||||||
@ -31,6 +31,8 @@ static std::string serverPort;
|
|||||||
Dial dial;
|
Dial dial;
|
||||||
static int clean_memory = 0;
|
static int clean_memory = 0;
|
||||||
|
|
||||||
|
std::unique_ptr<CMTServer> g_mgr_server;
|
||||||
|
|
||||||
void StartCgiServer() {
|
void StartCgiServer() {
|
||||||
zlog_info(zbt, "start deal cgi");
|
zlog_info(zbt, "start deal cgi");
|
||||||
|
|
||||||
@ -40,8 +42,8 @@ void StartCgiServer() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CMTServer> g_mgr_server;
|
|
||||||
void StartCMTServer() {
|
void StartCMTServer() {
|
||||||
|
sleep(2);
|
||||||
boost::asio::io_service io_service;
|
boost::asio::io_service io_service;
|
||||||
g_mgr_server = std::make_unique<CMTServer>(io_service, 10000); io_service.run();
|
g_mgr_server = std::make_unique<CMTServer>(io_service, 10000); io_service.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user