Skip to content
Snippets Groups Projects
Commit 40371791 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

MultiplexedSocket: consider unknown state as REFUSE

Allows to better handle new states in the future.

Change-Id: Ie8b28f9776d2c4ce8a45eb02f5af323a2ea37ffd
parent 9a4e98bf
Branches
No related tags found
No related merge requests found
...@@ -460,9 +460,13 @@ MultiplexedSocket::Impl::handleControlPacket(std::vector<uint8_t>&& pkt) ...@@ -460,9 +460,13 @@ MultiplexedSocket::Impl::handleControlPacket(std::vector<uint8_t>&& pkt)
if (pimpl.handleProtocolMsg(object)) if (pimpl.handleProtocolMsg(object))
continue; continue;
auto req = object.as<ChannelRequest>(); auto req = object.as<ChannelRequest>();
if (req.state == ChannelRequestState::ACCEPT) { if (req.state == ChannelRequestState::REQUEST) {
pimpl.onRequest(req.name, req.channel);
}
else if (req.state == ChannelRequestState::ACCEPT) {
pimpl.onAccept(req.name, req.channel); pimpl.onAccept(req.name, req.channel);
} else if (req.state == ChannelRequestState::DECLINE) { } else {
// DECLINE or unknown
std::lock_guard<std::mutex> lkSockets(pimpl.socketsMutex); std::lock_guard<std::mutex> lkSockets(pimpl.socketsMutex);
auto channel = pimpl.sockets.find(req.channel); auto channel = pimpl.sockets.find(req.channel);
if (channel != pimpl.sockets.end()) { if (channel != pimpl.sockets.end()) {
...@@ -470,8 +474,6 @@ MultiplexedSocket::Impl::handleControlPacket(std::vector<uint8_t>&& pkt) ...@@ -470,8 +474,6 @@ MultiplexedSocket::Impl::handleControlPacket(std::vector<uint8_t>&& pkt)
channel->second->stop(); channel->second->stop();
pimpl.sockets.erase(channel); pimpl.sockets.erase(channel);
} }
} else if (pimpl.onRequest_) {
pimpl.onRequest(req.name, req.channel);
} }
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment