|
|
@ -120,7 +120,7 @@ void ExtAPIService::initialize() { |
|
|
|
} |
|
|
|
|
|
|
|
string chname = webSocket.getUrl().substr(1); |
|
|
|
WbesocketConnectMgrService::insertNewClient(chname, findws(chname), make_shared<WebSocketConnectInfo>(connectionState->getRemoteIp())); |
|
|
|
WbesocketConnectMgrService::insertNewClient(chname, findws(&webSocket), make_shared<WebSocketConnectInfo>(connectionState->getRemoteIp())); |
|
|
|
} else if (msg->type == ix::WebSocketMessageType::Message) { |
|
|
|
string chname = webSocket.getUrl().substr(1); |
|
|
|
auto channel = DataChannelMgr::findByChannel(chname); |
|
|
@ -132,7 +132,7 @@ void ExtAPIService::initialize() { |
|
|
|
} else if (msg->type == ix::WebSocketMessageType::Close) { |
|
|
|
string chname = webSocket.getUrl().substr(1); |
|
|
|
logger->info("close connect ip: {},url: {}, channel:{}", connectionState->getRemoteIp(), webSocket.getUrl(), chname); |
|
|
|
WbesocketConnectMgrService::removeClient(chname, findws(chname)); |
|
|
|
WbesocketConnectMgrService::removeClient(chname, findws(&webSocket)); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@ -144,10 +144,15 @@ void ExtAPIService::initialize() { |
|
|
|
WbesocketConnectMgrService::findClientByName(fromch->getAlias(), clients); |
|
|
|
for (auto ch : clients) { |
|
|
|
if (ch) { |
|
|
|
WebSocketSendInfo sendInfo; |
|
|
|
if (binary) { |
|
|
|
ch->sendBinary(string(data, len)); |
|
|
|
sendInfo = ch->sendBinary(string(data, len)); |
|
|
|
} else { |
|
|
|
ch->sendText(string(data, len)); |
|
|
|
sendInfo = ch->sendText(string(data, len)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!sendInfo.success) { |
|
|
|
logger->error("send data to client {} failed", (int64_t)ch.get()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -184,12 +189,12 @@ void ExtAPIService::initialize() { |
|
|
|
logger->info("======================================================"); |
|
|
|
}; |
|
|
|
|
|
|
|
shared_ptr<WebSocket> ExtAPIService::findws(string chname) { |
|
|
|
if (chname.empty()) return nullptr; |
|
|
|
shared_ptr<WebSocket> ExtAPIService::findws(WebSocket *ws) { |
|
|
|
if (!ws) return nullptr; |
|
|
|
|
|
|
|
auto clients = m_wsServer->getClients(); |
|
|
|
for (auto it : clients) { |
|
|
|
if (it->getUrl().substr(1) == chname) { |
|
|
|
if (it.get() == ws) { |
|
|
|
return it; |
|
|
|
} |
|
|
|
} |
|
|
|