diff --git a/resources/spd_logger_cfg.json b/resources/spd_logger_cfg.json index 1d1ca4a..a3df2cf 100644 --- a/resources/spd_logger_cfg.json +++ b/resources/spd_logger_cfg.json @@ -20,6 +20,14 @@ "type": "stdout_color_sink_mt" }, { + "name": "ZCanReceiverHost", + "level": 0 + }, + { + "name": "ExtAPIService", + "level": 0 + }, + { "name": "root", "type": "logger", "level": 2, diff --git a/src/configs/version.hpp b/src/configs/version.hpp index 28d3f8e..5e6344d 100644 --- a/src/configs/version.hpp +++ b/src/configs/version.hpp @@ -1,2 +1,2 @@ #pragma once -#define VERSION "2.3" \ No newline at end of file +#define VERSION "2.4" \ No newline at end of file diff --git a/src/service/extapi_service.cpp b/src/service/extapi_service.cpp index 18dd10d..e651bab 100644 --- a/src/service/extapi_service.cpp +++ b/src/service/extapi_service.cpp @@ -119,8 +119,17 @@ void ExtAPIService::initialize() { logger->info("\t{}: {}", it.first, it.second); } - string chname = webSocket.getUrl().substr(1); - WbesocketConnectMgrService::insertNewClient(chname, findws(&webSocket), make_shared(connectionState->getRemoteIp())); + string chname = webSocket.getUrl().substr(1); + static int id; + + auto cinfo = make_shared( // + msg->openInfo.uri, // url + connectionState->getRemoteIp(), // ip + chname, // chanme + fmt::format("{}{}({})", chname, id++, connectionState->getRemoteIp()) // + ); + + WbesocketConnectMgrService::insertNewClient(chname, findws(&webSocket), cinfo); } else if (msg->type == ix::WebSocketMessageType::Message) { string chname = webSocket.getUrl().substr(1); auto channel = DataChannelMgr::findByChannel(chname); @@ -143,6 +152,8 @@ void ExtAPIService::initialize() { WbesocketConnectMgrService::findClientByName(fromch->getAlias(), clients); for (auto ch : clients) { if (ch) { + shared_ptr cinfo = WbesocketConnectMgrService::findwsinfo(ch); + WebSocketSendInfo sendInfo; if (binary) { sendInfo = ch->sendBinary(string(data, len)); @@ -150,8 +161,10 @@ void ExtAPIService::initialize() { sendInfo = ch->sendText(string(data, len)); } - if (!sendInfo.success) { - logger->error("send data to client {} failed", (int64_t)ch.get()); + if (sendInfo.success) { + logger->debug("send data to client {} {} success", cinfo->getConnUniqueId(), binary ? StringUtils().bytesToString(data, len) : string(data, len)); + } else { + logger->error("send data to client {} failed", cinfo->getConnUniqueId()); } } } diff --git a/src/service/wbesocket_connect_mgr_service.cpp b/src/service/wbesocket_connect_mgr_service.cpp index 1343bcf..cf8f766 100644 --- a/src/service/wbesocket_connect_mgr_service.cpp +++ b/src/service/wbesocket_connect_mgr_service.cpp @@ -11,7 +11,7 @@ static map>> wsClients; static map> wsClientsInfo; static std::mutex wsClientsLock; -shared_ptr findwsinfo(shared_ptr client) { +shared_ptr WbesocketConnectMgrService::findwsinfo(shared_ptr client) { if (client == nullptr) return nullptr; auto it = wsClientsInfo.find((void *)client.get()); if (it == wsClientsInfo.end()) return nullptr; diff --git a/src/service/wbesocket_connect_mgr_service.hpp b/src/service/wbesocket_connect_mgr_service.hpp index f4e52dc..eec74fc 100644 --- a/src/service/wbesocket_connect_mgr_service.hpp +++ b/src/service/wbesocket_connect_mgr_service.hpp @@ -31,12 +31,23 @@ using namespace nlohmann; using namespace ix; class WebSocketConnectInfo { + string url; string remoteIp; + string chname; + string connUniqueId; public: WebSocketConnectInfo() {} - WebSocketConnectInfo(string ip) : remoteIp(ip) {} + WebSocketConnectInfo(string url, string remoteIp, string chname, string connUniqueId) { + this->url = url; + this->remoteIp = remoteIp; + this->chname = chname; + this->connUniqueId = connUniqueId; + } string getRemoteIp() { return remoteIp; } + string getUrl() { return url; } + string getChannelName() { return chname; } + string getConnUniqueId() { return connUniqueId; } }; class WbesocketConnectMgrService { @@ -47,6 +58,8 @@ class WbesocketConnectMgrService { static json getConnectionList(); static void updateConnectList(); + + static shared_ptr findwsinfo(shared_ptr client); }; } // namespace iflytop diff --git a/tools/deply.sh b/tools/deply.sh index b048c52..a1d06cc 100755 --- a/tools/deply.sh +++ b/tools/deply.sh @@ -9,7 +9,9 @@ fi server=$1 ssh $server 'mkdir -p /iflytopd/iflytophald/' +ssh $server 'systemctl stop iflytophald' scp ./build/app/iflytophald $server:/iflytopd/iflytophald/ # scp ./resources/iflytophald.service $server:/lib/systemd/system/ # scp ./resources/config.ini $server:/iflytopd/iflytophald/ scp ./resources/spd_logger_cfg.json $server:/iflytopd/iflytophald/ +ssh $server 'systemctl start iflytophald' \ No newline at end of file